我的程序保持seg错误并使用gdb运行直到它进入无限循环。我无法弄清楚为什么会这样做,有人可以帮助我吗?
char tmpstring[1024];
char* fileName;
off_t size;
char* pos;
char *token;
int total = 0;
char* kiloCheck;
char* tstallCheck;
char* tmomCheck;
while (fgets(tmpstring, 1024, stdin))
{
fileName = tmpstring;
//remove newline
if ((pos=strchr(fileName, '\n')) != NULL)
*pos = '\0';
token = strtok(fileName, s);
//walk through tokens
while(token != NULL){
size = filesize(token);
total += size;
token = strtok(NULL, s);
}
}