|
|
May I know why size of int is only 4 byte in 64bit OS? Why it has not changed as it changed previously with 16 bit and 32 bit OS.
|
|
|
|
|
|
in mfc how i can read and convert data of any type to binary ???
|
|
|
|
|
Any data is already binary (you could do bitwise operations to extract individual bits). What exactly do you want to achieve?
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
As Rajesh said, your computer is a binary device and so all data is stored as binary.
Here is some code that displays an 8 bit data as binary.
You can extend the same for any other data type.
for (unsigned i = 0; i < 8; ++i)
cout << (datatype & (1 << i)) ? '1' : '0';
|
|
|
|
|
hi there i am working on a project that reads some data from a file and storing it into nodes. i actually made some operations like adding,deleting,search ect. in singly linked list with one structure type. now i am trying to use two structure types which are;
typedef struct node {
int birth_date;
int zipcode;
int phone_num;
char first_name[50];
char last_name[50];
char city[50];
char address[50];
char email_addr[50];
struct node* fn_next;
struct node* ln_next;
struct node* birdat_next;
} NODE;
typedef struct {
int count;
NODE* head;
NODE* tail;
NODE* current;
}LIST;
and this is the block which i read and store the data and finally call add_Node function;
while ( !feof(myfile) ) {
if( !(student = (NODE*) malloc(sizeof(NODE))) ) {
printf("ERROR NOT ENOUGH MEMORY!!!\n");
exit(100);
}
fscanf(myfile,"%s", &(student->first_name) );
fscanf(myfile,"%s", &(student->last_name) );
fscanf(myfile,"%s", &(student->email_addr) );
fscanf(myfile,"%d", &(student->phone_num) );
fscanf(myfile,"%s", &(student->address) );
fscanf(myfile,"%s", &(student->city) );
fscanf(myfile,"%d", &(student->zipcode) );
add_Node(&list,student);
printf("%s\n", student->first_name );
}
}
and of course add_Node function;
void add_Node(LIST** list, NODE* student) {
if( (*list)->head == NULL ) {
student->fn_next = (*list)->head;
(*list)->head = student;
(*list)->tail = student;
printf("Adding operation is succesfull\n");
(*list)->count++;
return;
}
else {
(*list)->current = (*list)->head;
while ( (*list)->current != NULL )
(*list)->current = (*list)->current->fn_next;
(*list)->current->fn_next = student;
student->fn_next = NULL;
(*list)->tail = (*list)->current;
return;
}
}
i am taking segmentation faults in add_Node and i don't know how to fix it.
|
|
|
|
|
Sure it goes wrong, as this statement
while ( (*list)->current != NULL ) (*list)->current = (*list)->current->fn_next;
is bound to result in (*list)->current being zero/null, hence the following
(*list)->current->fn_next=...
will bomb.
Some ideas:
1.
if you want to add a node at the end of the list, and your data structures have a tail member, why not use it, rather than scanning the list?
2.
try not to have special cases. When done properly, one often does not need them. And when one does, try making the alternate paths as short as possible, they tend to have common things (such as return, and count++ of which you forgot one).
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
i changed my way to implement the linked list with only NODE structure which is the way i know well. but this fault is not acceptable for me, i am angry to myself now because i want implement to list with using LIST structure. anyway, could you explain why i can't print the data with using code like this --> list->head->first_name
|
|
|
|
|
I did not tell you to drop the LIST structure; if you want new nodes added at the tail, having a tail pointer is the obvious way of doing it, as it is much faster than searching for the last node each time.
And your original code would never reach the print statement as it bombs when you use the null reference that is the resulting of spinning the while loop. So either use the tail pointer and drop the while loop, or fix the while loop.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
This is obviously an assignment but I'll give you some ideas.
a. It's better to use an existing container like std::list but if this is C and you don't have one or you have to write your own linked list then ...
b. You don't need to store current. I also assume you store tail and count for efficiency as you can work these out too.
c. You store tail but then in add_Node() you scan the list for the end anyway.
d. It may be simpler just to add new students to the start of the list rather than the end.
NODE * tmp = head;
head = student;
student->next = tmp;
e. If you step through your code the bvious problem is assigning through a NULL pointer. Why not do it like this:
void add_Node(LIST** list, NODE* student)
{
NODE ** pcurr;
for (pcurr = &head; *pcurr != NULL; pcurr = &((*pcurr)->next) )
;
*pcurr = student;
student->next = NULL;
}
Andrew Phillips
http://www.hexedit.com
andrew @ hexedit.com
|
|
|
|
|
hi andrew;
firstly, i must create my own linked and i know how to create it and i know how to make some simple operations with linked list. but this is the first time i want to use LIST structure(as you can see there is a head,tail,current and count). for example i wanna use like this;
list->head->first_name
and logically isn't it true_?. in main function the code is work well if i use like this
printf("%s\n", student->first_name );
but if use like this it isn't working. so what is the difference_?.
printf("%s\n", list->head->first_name );
|
|
|
|
|
> printf("%s\n", list->head->first_name );
Yes, this should work. It could be that list or list->head are NULL or uninitialised.
Try:
printf("%p %p %s\n", list, list->head, list->head->first_name );
which will print out the values of the pointers. Or step through the code and look at the values in the debugger.
Andrew Phillips
http://www.hexedit.com
andrew @ hexedit.com
|
|
|
|
|
Andrew Phillips wrote: printf("%p %p %s\n", list, list->head, list->head->first_name );
I guess one needs separate print statements here, as if one argument bombs, nothing will be printed at all.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
i opened another project to implement the list with LIST and NODE structure. but i am facing with an error. i couldn't fix it.
the error is;
expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
and the error is in create_list function which is;
LIST* create_list(void)
{
LIST* list;
list = (LIST*) malloc(sizeof(LIST));
if (!list) {
printf("ERROR NOT ENOUGH MEMORY!!!\n");
exit(100);
}
else {
list->count = 0;
list->current = NULL;
list->head = NULL;
list->tail = NULL;
}
return list;
}
and this is the main function;
LIST* create_list(void);
int main( void ) {
LIST* list;
list = create_list();
build_list(list);
print_list(list);
return 0;
}
|
|
|
|
|
most compilers give file name (and/or class name) and line number; tell your IDE to always show line numbers in editor windows. And try double-clicking the error message, any of these measures should bring you right to the objectionable statement.
BTW: Did you provide the definition of NODE and LIST before referencing them in your source code?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
i can see the location of error when i double clicked .
this is the line which error appears in create_list.h
LIST* create_list(void)
|
|
|
|
|
well i solved the problem. and this is the most stupid problem i have ever faced. it takes for hours to see. i only changed the location include "structures.h" with include "create_list.h" . so know create_list function can realize the structures
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I have created a test client application using WTClient.DLL to connect to matrikon OPC Server demo version. The WTClient.DLL has functions to interface the client application with the OPC Server. The client application basically exchange values with the server by creating the server tags (variables). The WTClient.DLL has callback functions used to update the client application tags with values from the server.
When there is an update of any of the value in the created tags the Matrikon OPC server issues callback to the client using the WTClient.DLL. Using the Callback function I update the changed values. However during sometimes after connecting my client application with the server, the callback does not happen even there is a change in the server data.
The code is as follows:
void CALLBACK EXPORT OPCUpdataCallback (HANDLE hGroup, HANDLE hItem, VARIANT *pVar, FILETIME timestamp, DWORD quality)
{
//Call to my function for updating the values (pVar) using the Handle hItem.
}
When I reopen my Client Application, it works fine. Again during sometimes the problem comes and so my application becomes unreliable.
Anybody Kindly help me to find out why my callback is not called from the server. My server is a standard application which is not supposed to have any errors
modified on Saturday, April 30, 2011 7:49 AM
|
|
|
|
|
Since this is an intermittent problem, it might be hard to track down. You need to strip down your client to the smallest possible app, that demonstrates this problem. Does the matrikon OPC Server come with source code for a demo client? If so, does that demo exhibit the problem? Again, try to boil it down to the smallest possible app. It is also very important to check the return codes of all functions, to see if there is an error.
If none of this works out, then check if there is a user forum for matrikon OPC Server. It might be something simple, which can be answered quickly.
Finally, of course, you could simply send an email to the vendor (I'm assuming matrikon OPC Server is a commercial product).
|
|
|
|
|
Just SendMessge to the Button IDC_BUTTON1 and make sure the button will be clicked
what's the code ?
thanks for help!
|
|
|
|
|
If you're not using MFC, the following would be the code, where hDlg is the handle to the dialog hosting the button -
::SendMessage(hDlg, WM_COMMAND, (BN_CLICKED << 16) | IDC_BUTTON1, ::GetDlgItem(hDlg, IDC_BUTTON1);
If you're using MFC, the following would be the version if you're calling it from within the dialog class -
SendMessage(WM_COMMAND, (BN_CLICKED << 16) | IDC_BUTTON1, GetDlgItem(IDC_BUTTON1));
|
|
|
|
|
ERROR,parameter 3...
SendMessage(WM_COMMAND, ((WPARAM)BN_CLICKED)<<8|(WPARAM)IDC_BUTTON, 0L); is that right?
I want the Button will be clicked down when the Message send,but there's nothing happened with the Button while the Message sent ,why
|
|
|
|
|
If you want to emulate a human pressing a button, then you will have to perform the actions a human performs:
1. Press button: send WM_LBUTTONDOWN
2. Hold button down a while: use SetTimer() or similar to implement delay.
3. Release button: send WM_LBUTTONUP.
|
|
|
|
|