I have the following program,
int iIndex=0;
char cPort[5]={"\0"};
char cFileChar;
fopen_s(&fFile,"c:\\Config\\FileName.txt","r");
if(fFile !=0)
{
cFileChar = getc(fFile);
while (cFileChar!= EOF)
{
cPort[iIndex]=cFileChar;
iIndex++;
cFileChar = getc(fFile);
}
iDIPort=atoi(cPort);
}
in the file I have 32000, but when the program execute and read from the file sometime its read fine and set iDIPort to 32000 but sometime it set the variable value to 320000.
Kindly help me to sort out this problem.