我需要从控制台读取输入并将其放入一个字符数组中。我编写了以下代码,但是我得到了以下错误:“分段错误”。
#include <stdio.h>
#include <stdlib.h>
int main() {
char c;
int count;
char arr[50];
c = getchar();
count = 0;
while(c != EOF){
arr[count] = c;
++count;
}
return (EXIT_SUCCESS);
}