I learned that char array for string like char s1[10] = "Hello";
has to be initialized with value when it's declared.
But, with scanf
, it seems like I can declare it without initializing.
I'm wondering how it works.
e.g.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
char s1[6];
s1 = "Hello" // It does not work.
scanf("%s", s1); // And write Hello, it works. Why does it work?
return 0;
}
Thank you for reading