Hi guys, it will be helpful if someone can check my code and try to correct me....im trying to read a .txt file where inside this file all the hex values
18 77 FF 12 F8 6B 18 00 FF 03 F8 68 18 00 FE FF B8 77 FF 12 F8 6B 18 00 FF 03 F8 68 18 00 FE FF B8 F7 77 00 00 F8 10 11 00 10 12 72 85 02 12 48 00 F0 01 00 F8 3B 80 81 76 B6 03 10
i want to read each line at a time and add all the values on that line to get the total value. each line has 32 hex value.
here is my program:
Code:
char filename[] = "C:\\MYFlashValues.txt";
ifstream inputfile;
int MYArray[32];
// opening input file for reading
inputfile.open(filename, ios::in);
// test if fail to open the file, do…
// error handling for file opening
if(inputfile.fail())
{
Message( "file opend properly")
exit(1);
} // just exit
else
{
int chksum = 0;
int Valuecount=0;
char addrs=0;
char RecordType=0;
int temp=0;
char value;
short Number;
short Two;
int endchksum=0;
int ArrayCnt=0;
// read data from input stream...
while(!inputfile.eof())
{
getline(inputfile, Value);
temp= ArrayCnt % 32;
if((temp==0)&&(ArrayCnt!=0))
{
for(int x=0;x<32;x++)
{
chksum+=MYArray[x];
chksum=chksum*0xFF;
}
how can i add hex values?? also i have space between each hex value how can i ignore space and add all the hex values...pls help