hi there.....i wonder what's the difference with these 2 linked list...

1.
struct node
{
	int wage;
	int hours_worked;
	int salary;
	int hoursW; 
	char* name;
	struct node *link;
};
2.
struct listNode 
{			
   char data;	
   struct listNode *nextPtr; 
}; 
typedef struct listNode ListNode; /* synonym for struct listNode */
typedef ListNode *ListNodePtr; /* synonym for ListNode* */

and this....

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.

char str[255] = "Hello";

in the above, sizeof(str) is 255, but strlen(str) is only 5.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.