Pointers and Strings

#include <stdio.h>
#include <string.h>

int main() {
char *name="David Bolton";
printf("My name is %s\r\n",name) ;

return 0;

The line char * name="David Bolton"; defines name as a pointer to the first character in the string. The assignment means that as soon as the program loads, the pointer is set to hold the address of where the string is stored.

printf("The address of name is %x\r\n",(int)&name) ;
printf("The address that *name points to is %x\r\n",(int)name) ;

%x prints the addresses in hexadecimal. The \r\n outputs a Carriage Return and a Linefeed character.
(int)&name has two important parts. (int) converts the pointer type to an int. &name means the address of the variable name.

Output is:
My name is David Bolton
The address of name is 7fe78
The address that name points to is 408004