I am trying to open a text file which contains a dictionary of english words. Each word and it's definition are on the same line and the entries are delimited by a newline. Now, my question is that if you open a text file using fopen() in "rt" mode then do the newlines have a \r\n or just \n? In binary mode does the newline get interpreted as \r\n or just \n? Massive confusion!
anumash 0 Newbie Poster
Recommended Answers
Jump to PostFrom your question, I assume you are using a Windows system? Do you know if the files are in MS, or in Unix/Linux format?
Jump to PostOk. On Windows, a text newline ('\n') IS a carriage-return+linefeed ('\r\n') combination. You would only need to use the latter representation if you were reading the file from Unix/Linux systems. On Windows, it is still encoded as '\n'. IE, don't sweat it unless you are reading a file from one …
Jump to PostWhen you have a string of words - here a word, and then it's definition, on the same line, you want to use fgets() and put the entire line into a char array (I use "buffer", all at once.
The newline will be included on the end of the buffer …
All 12 Replies
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
anumash 0 Newbie Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
anumash 0 Newbie Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
anumash 0 Newbie Poster
anumash 0 Newbie Poster
Adak 419 Nearly a Posting Virtuoso
anumash 0 Newbie Poster
anumash 0 Newbie Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.