#include<stdio.h>
int main(void)
{
char letter;
char *pletter;
pletter = &letter;
printf("%p", &letter;
putchar('\t');
printf("%p", letter);
putchar('\n');
puts("Understand?\nWhat is the right way? it is 4bytes different");
//*allows the value to be altered by the base adderess
//&lets a datatype to value by its adderess from another datatype takes 2 datatypes of same size(bytes)
return 0;

Is there a question somewhere ? Or do you just like to post code?

#include<stdio.h>
int main(void)
{
char letter;
char *pletter;
pletter = &letter;
printf("%p", &letter;
putchar('\t');
printf("%p", letter);
putchar('\n');
puts("Understand?\nWhat is the right way? it is 4bytes different");
//*allows the value to be altered by the base adderess
//&lets a datatype to value by its adderess from another datatype takes 2 datatypes of same size(bytes)
return 0;

For future, please don't ask your question in the code. Ask in the text area. It took me three times longer to decypher your question...

The reason is that it's is simpler for the system allocate the variables on 4-byte boundaries. So if you have a char* array of 6 bytes, you'll see an 8-byte difference.

>>printf("%p", letter);
This produces undefined behavior. "%p" expects the parameter to be a pointer to some object, but you are passing the value of a character.

Garbage in, garbage out.

printf("I looked at it closer now I understand the & to get it from the adderess, that code always need to have the &.\nAbout using the right adderess, or it will not process the variable the right way.\n"); printf("I am sorry if I am making a nuisance outta myself or if I am making you work harder\n"); [\code][code=c]
printf("I looked at it closer now I understand the & to get it from the adderess, that code always need to have the &.\nAbout using the right adderess, or it will not process the variable the right way.\n");
printf("I am sorry if I am making a nuisance outta myself or if I am making you work harder\n");
[\code]

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.