text files & notepad problem

This is a discussion on text files & notepad problem within the C Programming forums, part of the General Programming Boards category; Hi folks, I seem to be having a problem with text files and notepad that I never seen before. A ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    247

    text files & notepad problem

    Hi folks,
    I seem to be having a problem with text files and notepad that I never seen before. A text file

    I create with a C program has suddenly decided not to recognise any "\n" charcters like before, so that

    when opened (Notepad as default) the whitespace character box appears...where the new line should be.

    A sample line of code (*fp is file pointer)
    Code:
    int Index = 0;
    
    for(Index = 0; Index < 10; Index++)
    	fprintf(fp,"This is line : \n", Index);
    Result on win 2000 pro (work) it works okay
    This is line : 0
    This is line : 1
    This is line : 2...ect.

    Whilst on win 98 SE at home is like this..

    This is line : 0 This is line : 1 This is line : 2 This is line : 3 This is line : 4 This is line : 5...ect

    only with the white space characters [box] in between each number and 'This'.

    Has anyone ever seen this before, is there a simple fix...I have written many programs which produce

    text files, this is the first time I have had this problem.

    Bigtamscot.
    hoping to be certified (programming in c)
    here's the news - I'm officially certified.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Did you open the stream in binary mode? If so, simple Windows based apps like Notepad will have trouble, as they expect CRLF as end of line markers, not just LF (\n).
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    247
    it's always something simple and yet it will trip you up and cause hours of headache trying to figure out what was wrong. I was convinced it was something to do with notepad. The other files i am working on in this program are binary files...so I opened the text file as binary...Thanks Hammer...live and learn...

    Tam.
    hoping to be certified (programming in c)
    here's the news - I'm officially certified.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 03:49 PM
  2. reading integers into arrays from text files
    By c_beginner in forum C Programming
    Replies: 6
    Last Post: 08-05-2004, 11:42 AM
  3. C: include files problem
    By threahdead in forum Linux Programming
    Replies: 4
    Last Post: 05-07-2004, 08:02 AM
  4. Problem with static text in dialog boxes
    By Clyde in forum Windows Programming
    Replies: 11
    Last Post: 05-28-2002, 12:51 PM
  5. displaying text files, wierd thing :(
    By Gades in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 04:18 PM

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