What is the identifier to print an address with printf?
Thursday, March 09, 2023
Add Comment
Question: What is the identifier to print an address with printf?
To print the address of a variable in C programming language using printf, you need to use the %p format specifier. This format specifier is used to print the memory address of a pointer variable. Here's an example:
int main() {
int num = 10;
printf("The address of num is: %p", &num);
return 0;
In the above example, the &num operator is used to get the memory address of the variable num. The %p format specifier is used to print the address in hexadecimal format.
0 Komentar
Post a Comment