| | |
What's the difference?(linked list)
![]() |
•
•
Join Date: Mar 2008
Posts: 4
Reputation:
Solved Threads: 0
hi there.....i wonder what's the difference with these 2 linked list...
and this....
i hope someone will answer me.........pls explain in simple english so that i can understand well...im not an American...=) thank a lot..peace!!
C Syntax (Toggle Plain Text)
1. struct node { int wage; int hours_worked; int salary; int hoursW; char* name; struct node *link; };
C Syntax (Toggle Plain Text)
2. struct listNode { char data; struct listNode *nextPtr; }; typedef struct listNode ListNode; /* synonym for struct listNode */ typedef ListNode *ListNodePtr; /* synonym for ListNode* */
and this....
C Syntax (Toggle Plain Text)
temp->name=(char*)malloc(strlen(tempString)+1); //this is based on the linked list example 1(above) //why this doesnt have sizeof? =)
i hope someone will answer me.........pls explain in simple english so that i can understand well...im not an American...=) thank a lot..peace!!
>>//why this doesnt have sizeof? =)temp->name=(char*)malloc(strlen(tempString)+1);
>>//this is based on the linked list example 1(above)
>>//why this doesnt have sizeof? =)
It doesn't use sizeof(tempString) probably sizeof(any pointer here) is only 4 on 32-bit machines while the length of the string can be much much more than that. And the size of a character array may or may not be the same as the length of the string in the array.
in the above, sizeof(str) is 255, but strlen(str) is only 5.
>>//this is based on the linked list example 1(above)
>>//why this doesnt have sizeof? =)
It doesn't use sizeof(tempString) probably sizeof(any pointer here) is only 4 on 32-bit machines while the length of the string can be much much more than that. And the size of a character array may or may not be the same as the length of the string in the array.
C Syntax (Toggle Plain Text)
char str[255] = "Hello";
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Recursive procedure (to display a linked list) (Pascal and Delphi)
- Linked list using ctrl+z out from loop.But doesn't work well... (C++)
- linked list error (C)
- Tuple List (Python)
- linked list implementation of stacks (C)
- How to delete a data structure in Builder 6.0? (C++)
- The difference between functions and templates? (C++)
Other Threads in the C Forum
- Previous Thread: Bitfields
- Next Thread: Capitalize letter in string to output... Should be a pretty easy solution!
| Thread Tools | Search this Thread |
adobe api array arrays binarysearch calculate char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators intmain() iso kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc program programming pyramidusingturboccodes read recursion recv recvblocked repetition research scanf scheduling segmentationfault send shape socketprograming socketprogramming stack standard strchr string suggestions systemcall test unix urboc user variable voidmain() wab win32api windows.h






