priyaranjan
Right off the assembly line
hi,
I have a problem in understanding the creation of object file just look at the code below. in the code below i have defined struct node in another C file. I have no any declaration of struct node in this code . But when i am compiling this code to generate the object code it is compiling.
gcc -w -c treestack.c
but when i m using struct node data in place of struct node *data it is not compiling .
can you explain why???
dont go to my code deeply just see the lines i have commented.
I have a problem in understanding the creation of object file just look at the code below. in the code below i have defined struct node in another C file. I have no any declaration of struct node in this code . But when i am compiling this code to generate the object code it is compiling.
gcc -w -c treestack.c
but when i m using struct node data in place of struct node *data it is not compiling .
can you explain why???
dont go to my code deeply just see the lines i have commented.
Code:
/* treestack.c */
#include<stdlib.h>
struct treestack
{
struct node * data; // when changes this line to struct node data
struct treestack *link;// it doesnt compile
};
struct treestack *temp;
struct treestack *top=NULL;
void push()
{
temp= (struct treestack *)malloc(sizeof(struct treestack));
printf("enter the data you wnt to");
scanf("%d",&temp->data);
temp->link=top;
top=temp;
}
void pop()
{
if (top==NULL)
{
printf("stack is empty");
return;
}
top=top->link;
}
void travel()
{
struct treestack *var;
var = top;
while(var != NULL)
{
printf("values in stack are %d",var ->data);
var =var->link;
}
}