So, I see pointers defined in many different ways but I never quite understood what the difference was. Could someone explain it to me?

Examples:

int * a; int* a; int *a

That second one may or may not be actual C++ but I've seen it done in all those ways.

This is the syntax for the declaration of a pointer to an integer, I guess the most common is int * a;
What is sometimes confusing is that dereferencing a pointer uses practically the same syntax int i = *a;
Here i will contain the integer value that is stored in the adress pointed to by pointer a.

It doesn't really matter where you put the space in the syntax, the compiler doesn't care. The examples you posted are all acceptable and correct. It's only a matter of programming style -- however you wish to do it.

Thank you to both of you! Really clears it up!

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.