Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

silly C problem

  • 09-08-2004 08:47AM
    #1
    Registered Users, Registered Users 2 Posts: 1,368 ✭✭✭


    Hey people,

    Something funny is happening when I write out to file. I was given a specific file format and I'm trying to get my program to generate this file format.

    The file format has three columns and multiple rows depending on how much data you gave. 1 row = 1 sample.

    I've written the code for writing to file, but when I open the file using notepad, "\n" seems not to have been interpreted as a newline, and all that is displayed is a black square where the newline should have been....

    I dont know if the problem is with the way notepad is interpreting the "\n", or if the problem is with my code?

    The file extension is .dat btw

    Thanks,
    Martin


Comments

  • Registered Users, Registered Users 2 Posts: 678 ✭✭✭briano


    try using textpad (http://www.textpad.com free to download)to view the dat files, It should display them properly. I had the same problem with notepad myself


  • Registered Users, Registered Users 2 Posts: 1,368 ✭✭✭king_of_inismac


    Thanks man,

    That has solved it! :D


  • Closed Accounts Posts: 47 PhilH


    Hi guys.

    What's happening here is that Windows expects a new line in a text file to be written as CR-LF (carraige return, ascii 13, followed by line feed, ascii 10). In
    C this is "\r\n".

    Unix, amonst other operating systems, expects just the \n.

    Some text editors, like WordPad, or TextPad, but not Notepad, are smart enough to interpret either convention.

    So, depending on who should be using the file you may still be in trouble. Strictly, your file does not contain valid line feed characters for Windows.

    PHiL


Advertisement