Menu

File Streams

2002-11-19
2012-09-26
  • Nobody/Anonymous

    I am trying to work with a file in binary mode.  I open the file, read it into a char [8191] buffer (then I look for data in the buffer) and try to loop through the file.  My Problem is I hit a EOF or Fail before the end of file.  Is there any known bug with binary file access using fstream?

    Am I better off using the old C methods?

    Thanks

    Kelly Burton
    Creator@darkhalf.com

     
    • Nobody/Anonymous

      I've had a lot more luck with C notation myself.  Sorry, I know that is a completely useless statement for solving your problem.

      Wayne

       
    • Nobody/Anonymous

      if you are using fstream yeah i would probably use standard c notation as you have access to fscanf() for this so you can use this piece of basic framwork

      #include <iostream>
      #include <stdio.h>
      #include <stdlib.h>

      int main(){
      FILE *fp;
      char ch;
      char line;
      if ((fp = fopen("File.txt","r")) == NULL) {
                       cout<<"error"<<endl; }
      while (ch != feof(fp)) {
      fscanf(fp,"[8190] %s", line);
      cout << line <<endl;
      }
      }

      Ie this should work only framework i havent complied this and dont if it will work and you can build on this i dont think  

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.