Hi coders,I have a small problem regarding pointers, I am a bit weak in pointers and need to understand why the following is wrong:

int main(void)
{
 char *a;
 gets(a);
 return 0;
}

This causes an exception, please explain the error. I am using Turbo C as compiler, suggest a good and latest compiler too! :)

If you're taking a class, use the compiler that the teacher will be testing you and your programs, with. There are two highly rated free C compilers that I know of. One is Microsoft's Visual Express (Google for a d/l site). The video is helpful to d/l as well.

The other is MingGW compiler, with Code::Blocks IDE. Google "Code::Blocks" for more info.

Turbo C won't handle newer C functions, or large memory demands, but it is simpler to use. It will easily handle simple graphics and non-buffered input, that both the above, will handle only with some difficulty.

Although I can't recommend Turbo C, I confess to using it with pleasure, for small stuff.

Narue has the pointer problem covered, below - typing slow, today.

>This causes an exception, please explain the error.
Simple, an uninitialized pointer is not a pointer to infinite memory. It's an invalid pointer.

Thanks for the answer.

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.