Asked by duncanb7
at 2024-11-05 09:46:35
Point:500 Replies:10 POST_ID:828778USER_ID:11059
Topic:
C Programming Language;C++ Programming Language;Linux
Recently , I am studing PHP explode() fuction convert C
at http://www.it.uu.se/katalog/larme597/explode
in which the example of explode() is working fine and but I
can not follow how it works.
Since I am not familar with C so I get the following simple basic questions.
For example, my code testing in C
#include <stdio.h>
int main (){
char h='a';
printf("=%c= =%d= =%d=",h,h,&h,);
// it will output "=a= =97= =1387254251="
//My question &h is address of char, h, but what is number of 97 stand for ?
char *g ="bc";
printf("=%c= =%c= =%d= =%d=",*g,*(g+1),g,&g);
//it will output "=b= =c= =4196522= =138725240="
//My question &g is address of pointer to g ?
//My question what is 4196522 stand for ?
//Why *(g+1) can get the second character of ("bc") ? whether g is address of the char
// or &g is address of char ?
}
I'm using gcc on 64 bit CentOS Linux
Please advise
Duncan
at http://www.it.uu.se/katalog/larme597/explode
in which the example of explode() is working fine and but I
can not follow how it works.
Since I am not familar with C so I get the following simple basic questions.
For example, my code testing in C
#include <stdio.h>
int main (){
char h='a';
printf("=%c= =%d= =%d=",h,h,&h,);
// it will output "=a= =97= =1387254251="
//My question &h is address of char, h, but what is number of 97 stand for ?
char *g ="bc";
printf("=%c= =%c= =%d= =%d=",*g,*(g+1),g,&g);
//it will output "=b= =c= =4196522= =138725240="
//My question &g is address of pointer to g ?
//My question what is 4196522 stand for ?
//Why *(g+1) can get the second character of ("bc") ? whether g is address of the char
// or &g is address of char ?
}
I'm using gcc on 64 bit CentOS Linux
Please advise
Duncan