Hi, I'm new to programming with c and I'm stuck with a small problem. I need to write a c program that opens a file in note pad.
The first line is the number 5, for how many rows of binary strings are to follow. Each line contains a string representing a binary number (with a maximum of 32 binary digits)
The program is supposed to read this file, and convert each binary number to base 10.
This is the binary code to test:
5
0110010101010100100101
10110
10000
01101101111001
1000000000001
And the programs supposed to write the results to a file called "results.txt"
here is what I've go:
Code:
#include <stdio.h>
int main (){
/* file input guide */
FILE *fPtr;
int i=33;
int j=6;
char name [33]= "d1.txt";
for (i=0;i<33;i++){
sprintf(name, "binary%03d.txt", i);
if((fPtr = fopen("data.dat","w")) == NULL){
printf("file data.dat could not be opened\n");
}else{
/* file processing follows */
fprintf(fPtr,"5\n0110010101010100100101\n10110\n10000\n01101101111001\n1000000000001\n",i,j);
fclose(fPtr);
}
}
return 0;
}