attempting to run the following code, and everything runs fine until i try to strcpy to the test
variable/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXTEXT 800
int main()
{
char test[MAXTEXT] = {0};
strcpy(test, getstr());
return 0;
}
getstr(){
int c, text_pos;
char text[MAXTEXT] = {0};
for(text_pos=0; text_pos < MAXTEXT && (c = getchar()) != EOF; text_pos++){
text[text_pos] = c;
}
return text;
}
the the program crashes with a segmentation fault. I'm new to C so I don't really understand what this all means.
thanks.