Linked List
Oct 10, 2012 at 2:05pm UTC
the following code gives an error-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include<stdio.h>
#include<conio.h>
struct NODE
{
int info;
struct NODE* next;
};
void func(NODE **start)
{
printf("%d" ,*start->info);
}
int main()
{
int d=3;
NODE *start;
start->info=d;
func(&start);
getch();
}
but the following code works..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include<stdio.h>
#include<conio.h>
struct NODE
{
int info;
struct NODE* next;
};
void func(NODE **start)
{
NODE* temp;
temp=*start;
printf("%d" ,temp->info);
}
int main()
{
int d=3;
NODE *start;
start->info=d;
func(&start);
getch();
}
why is it so?
Oct 10, 2012 at 2:11pm UTC
operator precedence.
1 2 3 4
void func (NODE **start)
{
printf("%d" , (*start)->info) ;
}
Oct 10, 2012 at 2:17pm UTC
@cire..thnk u so much
@aceix- cire is right..ur code is not wrking
Oct 10, 2012 at 3:40pm UTC
hey..i didnt use any malloc function to allocate memory to a node, then how memory got allocated??how m i able to use start->info without allocating memory!!??
plz rply asap
Oct 10, 2012 at 3:51pm UTC
then how memory got allocated?
It was not
how m i able to use start->info without allocating memory!
You are not
Last edited on Oct 10, 2012 at 3:51pm UTC
Topic archived. No new replies allowed.