Hi. I am having some problems with files. I am trying to read some contents from a file, transfer them to an array and then read the contents of the array. The problem that I am facing is that the output is not that is suppose to be. The file contains binary, and as an output I am getting only 0s. I cannot find the problem....can please someone help me? Thanks a lot.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define SIZE 1000
int i;
void CallingFile(void);
int main(void)
{
int Array[SIZE]={0};
int j;
FILE *cfPtr;
if((cfPtr = fopen("Error Pattern 2.dat","r") ) == NULL)
{
printf("File cannot be opened\n");
}/* end if */
else
{
//printf("Contents of file are:%d\n", cf);
for (j=0;j<SIZE;j++){
fscanf(cfPtr,"%d", &Array[j]);
printf("%d",Array[j]);
}
}
while(!feof(cfPtr))
{
printf("Contents of file are:%d\n", cfPtr);
fscanf(cfPtr,"%d", &Array);
}// end while
fclose(cfPtr);
return 0;
}