unknown file type reading

This is a discussion on unknown file type reading within the C Programming forums, part of the General Programming Boards category; Ok... but does it have the *correct* text content? byte by byte? The junk at the end is from what ...

  1. #16
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Ok... but does it have the *correct* text content? byte by byte?

    The junk at the end is from what I explained about the send not using the read size when sending data...

  2. #17
    Registered User
    Join Date
    Nov 2010
    Posts
    11
    here's the receiver content (the 'damaged' one):
    61 6C 67 75 6D 20 74 65 78 74 6F 0A 74 65 78 74 6F 0A 66 69 6D 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    original .txt:
    61 6C 67 75 6D 20 74 65 78 74 6F 0A 74 65 78 74 6F 0A 66 69 6D 0A

    it's the same info, except for the '00' characters

  3. #18
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    You'll have to use the return value of fread/recv to:
    1. Make sure your read succeeded.
    2. Find out how many bytes to send/write.

  4. #19
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by EVOEx View Post
    You'll have to use the return value of fread/recv to:
    1. Make sure your read succeeded.
    2. Find out how many bytes to send/write.
    That's what I've been saying, except he has the same fixed write size problem with his receiver function. There he will need to test the return value of recv to find out how many bytes to fwrite().

    Most likely it's writing garbage at the end of every file.

  5. #20
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by xixonga View Post
    here's the receiver content (the 'damaged' one):
    it's the same info, except for the '00' characters
    Then it's not the same info, is it?

    It's entirely possible that with so many trailing nulls, the text reader is interpreting it as a binary file and rejecting it.

  6. #21
    Registered User
    Join Date
    Nov 2010
    Posts
    11
    hi thanks for your replies...

    i did what you said (read nš of bytes from fread and send them) and it's working

    thank you for your help and your patience

    Best regards

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LDAP Query
    By Travoiz in forum C++ Programming
    Replies: 0
    Last Post: 08-13-2009, 02:58 PM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

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