hi guys, I found this code on the web but unable to integrate it into my code, can any1 help?. The problem is, it doesnt read till the eof, instead it stops when the condition is erroneously made.
#declare Line_Char_Buffer_Size 4000
#declare INPUT_FILE_NAME "Countries.txt"
void readData ()
{
FILE * pFile;
NoOfRecordsRead = 0;
char buffer [Line_Char_Buffer_Size];
pFile = fopen (INPUT_FILE_NAME , "r");
if (pFile == NULL)
perror ("Error opening file 'Countries.txt' !");
else
{
while ( !feof (pFile) )
{
char* aLine = get_line (buffer, Line_Char_Buffer_Size, pFile);
if (aLine != NULL)
{
// printf ("%d] aLine => %s\n", NoOfRecordsRead, aLine);
globalCountryDataArray [NoOfRecordsRead++] = createCountryRecord (aLine);
}
}
fclose (pFile);
}
}
Countries.txt
BH,Bahrain,BA,BH,BHR,48.00,Manama,Middle East,Bahraini Dinar,BHD,645361.00
BI,Burundi,BY,BI,BDI,108.00,Bujumbura,Africa,Burundi Franc,BIF,6223897.00
BJ,Benin,BN,BJ,BEN,204.00,Porto-Novo ,Africa,CFA Franc BCEAO,XOF,6590782.00
BM,Bermuda,BD,BM,BMU,60.00,Hamilton,North America,Bermudian Dollar,BMD,63503.00
BN,Brunei Darussalam,BX,BN,BRN,96.00,Bandar Seri Begawan,Southeast Asia,Brunei Dollar,BND,
BO,Bolivia,BL,BO,BOL,68.00,La Paz /Sucre,South America,Boliviano,BOB,8300463.00
BR,Brazil,BR,BR,BRA,76.00,Brasilia,South America,Brazilian Real,BRL,174468575.00
The output of program will stop at BN,Brunei Darussalam,BX,BN,BRN,96.00,Bandar Seri Begawan,Southeast Asia,Brunei Dollar,BND, and not continue further. How do i modify it such a way that it will read the entire text? Thanks in advance