Environment: VS2013 express, Windows 7.
Source codes are really simple:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int TestNum, k, idx;
char *strbuf1 = NULL;
strbuf1 = (char *)malloc(sizeof(char) * 10001);
if (strbuf1 == NULL){
printf("memory allocation failed\n");
return -1;
}
gets(strbuf1);
TestNum = atoi(strbuf1);
for (k = 0; k < TestNum; k++){
gets(strbuf1);
printf("k= %d, strbuf1=%s\n", k, strbuf1);
//--- read data ---//
idx = 0;
while (idx < 5){
gets(strbuf1);
idx ++;
}
}
return 0;
}
After building the codes into an executable file, say foo.exe, I tested it with "foo.exe < testinput.txt" under cmd window. It will break down all the way, but I can't tell why. Anybody has a clue?
I've uploaded the "testinput.txt" file onto the GDrive, https://docs.google.com/document/d/1d8jBPZfYYjtA9R1CldUZhyRvaAiK5Xk9K-mhE6dIDKU/edit?usp=sharing