| | |
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 ansi api array asterisks binarysearch calculate centimeter char character cm convert copyanyfile copyimagefile copypdffile cprogramme createcopyoffile createprocess() csyntax directory feet fflush fgets file floatingpointvalidation fork frequency function getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking highest homework i/o inches infiniteloop interest intmain() kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives match meter microsoft mqqueue mysql number oddnumber odf open opendocumentformat openwebfoundation owf pattern pdf performance posix power probleminc program programming pyramidusingturboccodes read recv recvblocked repetition scanf scheduling segmentationfault send single socketprograming socketprogramming stack standard strchr string suggestions systemcall unix urboc user variable voidmain() wab whythiscodecausesegmentationfault win32api windows.h






