Hi all, I'm new to C programming. I'm running the code in Visual Studio where it will read a text file and after reading the file using struct. It will filter the data based on the if else condition below. I'm getting the "Error - An unhandled win32 exception occured [472]" and i think it should be something to do with the string "i".
I didn't post the other code but please let me know if you need it.
Sample of data file:
9001:0002:9003: 0021:CLS
0001:0010:0003: 0021:CLS
I didn't post the other code but please let me know if you need it.
Sample of data file:
9001:0002:9003: 0021:CLS
0001:0010:0003: 0021:CLS
Code:
for (i = 0; i < count; i++){
isValid = true;
if (array[i].src < 1 || array[i].src > 1024){
isValid = false;
}
else
if (array[i].dest < 1 || array[i].dest > 1024){
isValid = false;
}
else
if (array[i].type < 1 || array[i].type > 10){
isValid = false;
}
else
if (array[i].port < 1 || array[i].port > 1024){
isValid = false;
}
else
if (strlen(array[i].data) < 1 || strlen(array[i].data) > 50)
isValid = false;
//if meets the condition above writes to correct txt file
if (isValid){
n1++;
fprintf(outFile, "%04d:%04d:%04d:%04d %s \n",
array[i].src,
array[i].dest,
array[i].type,
array[i].port,
array[i].data
);
printf("%d:%d:%d:%d %s \n");
}
else
{
//if do not meet the condition above writes to correct txt file
n2++;
fprintf(errorFile, "%04d:%04d:%04d:%04d %s \n",
array[i].src,
array[i].dest,
array[i].type,
array[i].port,
array[i].data
);
printf("%d:%d:%d:%d %s \n");
}
}
fclose(errorFile); //close error output file once done
fclose(outFile); //close correct output file once done
return 0;
}
Comment