problems printing out

This is a discussion on problems printing out within the C++ Programming forums, part of the General Programming Boards category; hi, im trying to output my files contents in binary to a memo window in my program but im having ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    99

    problems printing out

    hi, im trying to output my files contents in binary to a memo window in my program but im having some problems in the fact that it will only print out the first couple of bytes of the file into my window. I think the problem is that i need to create a loop through my buffer until it is empty (just a guess) but i did not know how to construct this. I added a line right near the bottom (commented out) which i thought would have done the trcik but it throws back an error saying i have called too many arguements.

    If anyone could pass on any suggestions i would be very appreciative

    thanks


    Code:
    
    
    TListItem * Item2 = ListView2->Selected;
    if(Item2)
    {
            /**************************************************************************/
    
             AnsiString text = Item2->Caption;
             TStrings * subItems = Item2->SubItems;
    
             AnsiString text1 = subItems->Strings[0];                      //  Getting the designated subitem names from table
             AnsiString text2 = subItems->Strings[1];
             int startPoint = text1.ToInt();
             int fSize = text2.ToInt();
    
            / ********************************************************************************
    */
    
    
          /*********************BUILDING THE FILES**************************/
    
    AnsiString EvidenceFile =    Label2->Caption;                  //getting evidence file path from lable
                  
    char *buffer = new char[fSize];
    
    ifstream myFile (EvidenceFile.c_str(), ios::in | ios::binary);
    
    
    myFile.seekg (startPoint,std::ios::beg);
    
    
    myFile.read(buffer, fSize*sizeof(char));
    
    
    Memo1-Lines->Add(buffer);                     //adding the output of my file
    
    //Memo1-Lines->Add(bufferf, Size*sizeof(char));                     THIS LINE WONT WORK, STATES TOO MANY ARGUEMENTS
    
       }
    
    }

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Make sure buffer is null terminated.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    99
    hi, thanks for the reply. By null terminated does that mean ending with '/0'. If so im not sure how I can add that to the end of my buffer as its filled by input from a file not standard input from myself, if that makes sense

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    It makes sense except for the can't do attitude...
    Hey... real quick, what does Memo1-Lines->Add(buffer); do? Assuming that is supposed to be Memo1->Lines->Add(buffer); Then maybe the memo parser handles null terminating ('\0'ing) each line. But I would guess the line buffers are not null terminated.

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    99
    i shall give it ago and see what happens! Could solve the problem I have as it seems to lock up now when it eventually does compile like its in some sort of infinate loop thing so hopefully this will solve my problem!

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    We'll see what happens.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with functions and for loops
    By slava in forum C Programming
    Replies: 1
    Last Post: 11-08-2008, 01:30 PM
  2. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 03:59 AM
  3. Printing using DrawText() or TextOut()
    By Eversman in forum Windows Programming
    Replies: 1
    Last Post: 05-24-2004, 01:12 PM
  4. Printing :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 10-10-2002, 03:49 PM
  5. Printing
    By Dual-Catfish in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 05-25-2002, 09:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21