Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

size of char *

Status
Not open for further replies.

thides

Programmer
Oct 5, 2002
2
CA
How does a char * figure out to be 4? I am using a VC++, and a Windows 98 OS. This is the code:

int main()
{
printf("%d", sizeof(char*));
}

result is 4

int main()
{
printf("%d", sizeof(char));
}

result is 1

char is one byte
char* is 4 bytes.

Could someone please explain the logic?
 
Code:
char*
is a pointer on char, not a
Code:
char
. So sizeof gives the size of a pointer which is 4 on PC architectures.

--
Globos
 
OK right I think I remember that... thanks for jogging my memory.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top