Binary/Text file

This is a discussion on Binary/Text file within the C Programming forums, part of the General Programming Boards category; Does anyone have any idea of what may cause a .txt file linked to a file descriptor for output, to ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    30

    Binary/Text file

    Does anyone have any idea of what may cause a .txt file linked to a file descriptor for output, to not be readable after char/strings are output to the text file? I am outputing char/strings to a .txt file using open(), read(), and write() and when I try and open the .txt output file to view what was output to it, I get "Could not open the file output.txt" gedit has not been able to detect the character coding. Please check that you are not trying to open a binary file. Select a character coding from the menu and try again." Any help would be greatly appreciated, and if the code is necessary I will post it as well.
    Last edited by jakemott; 11-23-2009 at 10:34 AM.

  2. #2
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    958
    Do you mean fopen() fread() and fwrite()?

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    30
    No im working like this.
    Code:
    #define BUFLEN 1024
    
    char buffer[BUFLEN];
    
    int fidSink;
    
    //  Open the file sinkOutFile.txt and obtain the file handler 
    fidSink = open("sinkOutFile.txt", O_WRONLY  | O_CREAT | O_TRUNC, S_IRWXO | S_IRWXU | S_IRWXG);
    
    //writing like this.
    write(fidSink, buffer, BUFLEN);
    This works and its funny becuase I can see the text in the .txt file on the icon of the file in the directory. It just acts like its not a text file when I try and open in gedit to view its contents.

  4. #4
    Registered User
    Join Date
    Sep 2008
    Posts
    30
    This has been cross posted here.
    Binary/Text file - Dev Shed

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

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