in this program, i want read hexadecimal numbers from data.txt, and creating checksum.
http://en.wikipedia.org/wiki/.hex
I have a problem witch reading numbers from .txt and putting them to: char pole[50];
in data.txt are for example:
10010000214601360121470136007EFE09D21901
and when program end, on the screen will be:
10010000214601360121470136007EFE09D21901
40
40 - is the checksum
program would reading numbers in period:
10
01
00
00
21 etc...
(sorry for my english)
#include <stdio.h>
#include <conio.h>
int main ()
{
char a,i,j;
char suc=0;
char pole[50];
int c;
FILE*read=fopen("data.txt","r");
while (fscanf(read,"%2X",&a))!=EOF)
{
for(i=1;i<=20;i++)
{
pole[i]=a;
suc+=(~a+1);
}
}
for (j=1;j<=20;j++)
printf("%X",pole[j]);
printf("\n checksum: %X",suc);
getch();
}