Thread: fread - what am I doing wrong

  1. #1
    Registered User
    Join Date
    Aug 2001

    fread - what am I doing wrong

    I'm supposed read the content of a file, trim its content and copy the trimed content to a secundary file.... somehow, it's not working like it was supposed to .... any idea ????

    PHP Code:
    if( (Buffer=fopen(m_Source_File"r" )) == NULL )
    MessageBox("Source File Not Found");
    freadSource_Textsizeofchar ),2048Buffer );
    pdest strstr(Source_Text,"ISUP MESSAGE MONITOR RESULT");
    Text_Trim_Begin pdest Source_Text;
    pdest strstr(Source_Text,"END ");
    Text_Trim_End pdest Source_Text +3;
    int i=Text_Trim_Begina=0i<Text_Trim_End;i++, a++)
      if( (
    Buffer =fopen(m_Destination_File"w+" )) == NULL )
    MessageBox("Destination File Not Found");
    int space Text_Trim_Begin Text_Trim_End 1;
    fwrite(pTitle_1,   sizeof(char), 82  Buffer);
    fwrite(pTitle_2,   sizeof(char), 82  Buffer);
    fwrite(Source_Text,sizeof(char), Text_Trim_EndBuffer);     // I belive the error is in this line .... not shure
    fwrite(pTitle_3,   sizeof(char), 82  Buffer);

    I'm a person with a simple taste...
    I only like the best.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Well if its a text file, stick to fgets() and fputs()

    Oh, and stick to code tags, not php tags

    > fread( Source_Text, sizeof( char ),2048, Buffer );
    This does NOT append a \0 to the data read
    > pdest = strstr(Source_Text,"ISUP MESSAGE MONITOR RESULT");
    This needs a \0 to work properly
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why is fread sometimes taking so long?
    By manugarciac in forum C++ Programming
    Replies: 2
    Last Post: 04-28-2007, 11:25 PM
  2. return value of fread()
    By m.mixon in forum C Programming
    Replies: 5
    Last Post: 07-24-2006, 06:31 PM
  3. Reasons as to why fread would fail
    By Happy_Reaper in forum C Programming
    Replies: 4
    Last Post: 04-08-2006, 11:41 AM
  4. fread item_size limit
    By nvoigt in forum C++ Programming
    Replies: 2
    Last Post: 03-30-2005, 08:08 AM
  5. God
    By datainjector in forum A Brief History of
    Replies: 746
    Last Post: 12-22-2002, 11:01 AM
Website Security Test