Temple of The Roguelike Forums
Development => Programming => Topic started by: Pueo on May 29, 2012, 09:56:52 PM
-
A quick yes or no question, does nCurses recognize the /n and act accordingly?
Example:
move(0, 0);
do {
curChar = fgetc(highScores);
if (curChar == EOF) {
break;
}
else {
addch(curChar);
}
} while ((curChar = fgetc(highScores)) != EOF);
In the addch(curChar) part, if it comes across a newline signal, will it move the cursor to a new line, or do I have to do it manually?
-
I don't know nCurses, so please ignore me if I'm wrong but are you sure that it is /n? All languages I know use the backslash to indicate an escape sequence, i.e. \n instead of /n. I guess you just made a typo in your post but I just wanted to be sure.
-
I don't know nCurses, so please ignore me if I'm wrong but are you sure that it is /n? All languages I know use the backslash to indicate an escape sequence, i.e. \n instead of /n. I guess you just made a typo in your post but I just wanted to be sure.
Actually, some languages even use '~' fyi. But it is a moot point because he is talking about the newline "character", not the "\n" string itself.
As to the actual question I don't know ncurses ;)
-
Actually, some languages even use '~' fyi.
Interesting. I really didn't know that. Thanks.
But it is a moot point because he is talking about the newline "character", not the "\n" string itself.
Yeah, you're right. I was a bit too tired when I wrote this but at least I did no harm by pointing that out.
-
I don't know nCurses, so please ignore me if I'm wrong but are you sure that it is /n? All languages I know use the backslash to indicate an escape sequence, i.e. \n instead of /n. I guess you just made a typo in your post but I just wanted to be sure.
Yeah, well I guess it is \n (I went and looked it up again).
Also, question addendum:
When I make the file, then try and print it (using the same code as above), it skips every other character.
Example, the first line is: Highscores (Press SPACE to continue)
But it shows: ihcrs(rs PC ocniu)
What am I doing wrong?
-
Look at your code. Every loop, your while condition reads a character:
while ((curChar = fgetc(highScores)) != EOF)
Then, inside the loop, you read another:
curChar = fgetc(highScores);
And you only print one of them:
addch(curChar);
You have the break condition in the loop already, so it should be while(1).
-
Ah, ok. I see that now.
Thanks, kraflab
Also, since you helped me solve that, I now know that nCurses does honor the \n.