scanf() (C Language ) confused me
Posted
by Nano HE
on Stack Overflow
See other posts from Stack Overflow
or by Nano HE
Published on 2010-06-17T01:41:40Z
Indexed on
2010/06/17
1:52 UTC
Read the original article
Hit count: 224
Hello.
When do I need to insert/don't insert &
for scanf()
in C? Thank you.
int main()
{
char s1[81], s2[81], s3[81];
scanf("%s%s%s", s1, s2, s3);
// If replace scanf() with the expression below, it works too.
// scanf("%s%s%s", &s1, &s2, &s3);
printf("\ns1 = %s\ns2 = %s\ns3 = %s", s1, s2, s3);
return 0;
}
//programming is fun
//
//s1 = programming
//s2 = is
//s3 = fun
© Stack Overflow or respective owner