strunct num
{
int count;
};

void main()
{
num n1;
num *p;
p=#
scanf("%d", p->count);
printf("%d", p->count);
}

when I attempting to do this one I got the error message like

0 Null pointer .....

Recommended Answers

All 10 Replies

Try scanf("%d", &(p->count));

1. struct num, not strunct
2. If compiling in C, then struct num n1; struct num* p; 3. p = &n1

You're living in the fast lane.
Before you can understand structures and pointers in C you should have learned that main is defined as: int main(void) or int main(int argc, char *arg[]) and in both cases it needs to return an int.

thanx for replay
can u explain briefly

I used void so, there is no need to return any value

thanku dude

I tried but I failed

thanx for replay
can u explain briefly

I used void so, there is no need to return any value

Inside a host operating system main will always return a value, because that's the way the C standard says it has to be.

thanku dude

I tried but I failed

Tried what, and failed at what? You need to show us what you tried or at least give us a brief explanation about your problem.

thanx for replay
can u explain briefly

I used void so, there is no need to return any value

You can drive your car without fastening seat belt, or walk through minefield :)
But it's risky!

So always use int main() and return zero if succesful (in which case you don't even need to write return because compiler does it automatically for you.

thanku dude I got it
thanks for ur help

ya exactly
I got this one
thanku very much

regards,
sambafriends

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.