Linked List

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?
operator precedence.

1
2
3
4
void func (NODE **start)
{
    printf("%d", (*start)->info) ;
}
@cire..thnk u so much

@aceix- cire is right..ur code is not wrking
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
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
Topic archived. No new replies allowed.