I was just wondering is this reading a file one byte per time?

int main ()
{
  FILE * pFile;
  int c;
  int n = 0;
  pFile=fopen ("myfile.txt","r");
  if (pFile==NULL) perror ("Error opening file");
  else
  {
    do {
      c = getc (pFile);
      printf("%c-",c);
    } while (c != EOF);
  fclose (pFile);
  }
  system("PAUSE");
  return 0;}

On line 6 you want to use "rb" not just "r" because just using "r" would read one character at a time. If you have a bunch of integers in your file that are two digits long but are represented as 4 bytes you will be reading only two characters in when you want to be reading in 4.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.