Hi, so ive been teaching my self pointers, and I just wanted to clarify what I assume so far.

You cant declare: int var1 = &var2;
You MUST use a pointer to store an address: int *var1 = &var2;

When assigning a pointer variable, it must always point to an address. So that means you cant go: int *var1 = var2;

So that means I can always assuming, when working with a pointer, the format when declaring one is ALWAYS :

if your initilizing it:
Datatype *varName = &varName;

if your assigning it:
varName(early declared as a pointer) = &varName;

Ive tested all this and it proves to be true, but I was wondering if you guys had any further input. Thanks =D

Recommended Answers

All 2 Replies

>>When assigning a pointer variable, it must always point to an address.

Thats incorrect. Hint what about null pointers?

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.