Автор | Сообщение |
|
Отправлено: 07.07.17 20:05. Заголовок: What is this program not compiling?
This is the program: #include<stdio.h> int main() { char c[]; printf("Enter your sentence: "); scanf("%s",&c); printf("\n%s",c); return 0; } I have no idea why isn't this compiling. The error message says "Array size mising" but I had watched a tutorial where the array size was not given but still it compiled and ran correctly. But this one is not compiling. Please help.
|
|
|
Ответов - 1
[только новые]
|
|
|
Отправлено: 07.07.17 20:36. Заголовок: You did not specify ..
You did not specify the size of the array. The program can look like #include<stdio.h> #define N 100 int main( void ) { char s[N]; printf( "Enter your sentence: " ); scanf( "%99s", s ); printf( "\n%s", s ); return 0; } However if you are going to enter a sentence then you need to use the standard function fgets instead of scanf. Take into account that according to the C standard the function main without parameters shall be declared like int main( void )
|
|
|