#include <stdio.h>
char s[]="sfksfls\n";
void main()
{
printf(s);
}
Why it can work? I just input the char pointer to printf
#include <stdio.h>
char s[]="sfksfls\n";
void main()
{
printf(s);
}
Why it can work? I just input the char pointer to printf
A string literal in C is a pointer to const char
. printf
takes a pointer to const char
(plus an optional list of additional arguments). Passing it directly or through a variable makes no difference, a pointer is a pointer, it's just a number.