./n a the end of each sentence in output


#1

Hi,

I’m enjoying the book so far but am having some issues with the output of my programs. It seems every sentence ends with ./n when in the book it says it shouldn’t.

For example, the Turkey program outputs:

“The turkey weighs 14.200000./nCook it for 228.000000 minutes./nProgram ended with exit code: 0”

whereas from the book I should get

“The turkey weighs 14.200000. Cook it for 228.000000 minutes.”

Should I worry? I’m using XCode 5 on Mavericks


#2

Check to make sure that your format strings end with the new-line character ‘\n’, not with “/n”.

printf ("I like Foo and FooBar!\n");        // '\n' is a single character, the new-line character
// printf ("I like Foo and FooBar!/n");     // "/n" consists of two characters: '/' and 'n'

#3

Thanks a lot, knew it would be a typo!
Should I worry about the “Program ended with exit code: 0” at the end?

Thanks again


#4

[quote]Should I worry about the “Program ended with exit code: 0” at the end?
[/quote]
No, because exit code: 0 from a well written program usually means good.