Reading a string with scanf

I'm a little bit confused about something. I was under the impression that the correct way of reading a C string with scanf() went along the lines of

(never mind the possible buffer overflow, it's just a simple example)

char string[256];
scanf( "%s" , string );

However, the following seems to work too,

scanf( "%s" , &string );

Is this just my compiler (gcc), pure luck, or something else?

136
задан Valentin Michalak 29 June 2018 в 09:26
поделиться