This is very close to what you want, and works fine:
Code:
#include <stdio.h>
int main() {
int i;
char buff[80];
int mark[40];
printf("\n\n\n");
i=0;
while((fgets(buff, sizeof(buff), stdin))!=NULL) {
if(buff[0] == '\n') //handles last text line has newline
break;
printf("buff: %s", buff);
sscanf(buff, "%d%*c %d%*c %d%*c %d%*c", &mark[i],&mark[i+1],&mark[i+2],&mark[i+3]);
printf("%d, %d, %d, %d", mark[i],mark[i+1],mark[i+2],mark[i+3]);
i+=4;
printf("\n\n");
}
printf("\n\n\t\t\t press enter when ready");
(void) getchar();
return 0;
}
the %*c format is just "scan, but don't store this char", format. Handles the commas, and newline, but may not be required to work. Imo, scanf() is picky, and being explicit handling the char's, gets the coding done with fewer mistakes.