I have been struggling with this for over an hour now and I can't seem to find out why I get this error.
int inp, count;
char numBuff[21];
count = 0;
while((inp=getchar()) != EOF) { // get Value (last field)
printf("input is '%c'\n", inp);
if (inp == '\n') break;
if (inp == ' ') {
continue;
}
numBuff[count++] = inp;
printf("go back through loop\n");
}
printf("Out!");
numBuff[count] = '\0';
if I input 1013 I get the following
input is '1'
go back through loop
input is '0'
go back through loop
input is '1'
go back through loop
input is '3'
go back through loop
input is '
'
Segmentation fault (core dumped)
The only thing I can gather from this is that it is failing when I check if inp == '\n' but why? I moved the go back through loop printf to just after the check if inp == '\n' and it never reached that one either so I know that it is occurring there.