i kind of need to extract data from a code.txt which continues

0100000000001000000000000000000001100010011001
0100000000001000000000000000000001000000000000
0100000000001000000000000000000000000010001001
0100000000001000000000000000000000000001001001
0100000000001000000000000000000100100011001001
0100000000001000000000000000000000000000001001
0100000000001000000000000000000010100010101001
0100000000001000000000000000000010100001101001
0100000000001000000000000000000110100011101001
0100000000001000000000000000000011000000110010
0100000000001000000000000000000011110010111101

my main idea is to extract the number of ones in from each row ,each row = pulses converted from interrupt so as to compare with the number of ones detected when button on remote is pressed.

my current code is

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
FILE *infile;
char data[10][45],temp[45],buffer[256];
char *fixed="48";
int row,col,count45=0,i,binary,index;
main()
{
infile=fopen("codes.txt","r");
if(infile == NULL)//if file missing

        {

        printf("file missing!");

        }

        else

        {

         while(!feof(infile)) //scans file till end of file is reach and output to sysstem

         {

fgets(buffer,sizeof(buffer),infile);    
while(buffer[index])
{        
printf("%c",buffer[index]);
index++;   
}

}
}






system("pause");
}
This article has been dead for over six months. Start a new discussion instead.