2015-09-05 17 views
1

我剛剛寫了一個程序(非常簡單),但我有一個有點傻的問題:當我輸入/n來顯示下一行的輸出時,輸出始終顯示所有在一行中並且也打印/n/n新行錯誤C

下面是我在談論該計劃的一部分:

printf("Your gross salary is: %0.2f /n", GS); 
printf("The amount of your income tax is: %0.2f /n", Taxes); 
printf("Your net salary is: %0.2f /n", NS); 

,這就是它打印:

你的工資總額爲:400.00 /N你的收入稅額是:60.00 /N你的淨工資爲:340.00 /N

有誰知道爲什麼發生這種情況,並會爲w希望幫助我?

+1

參加[旅遊,學習[問]併發布[mcve]。 – Olaf

回答

5

/n不是換行符。它是一個雙字符序列,其中一個/後跟一個n。你需要字符\n

2

/不是轉義字符。轉義字符是\。通過\,您明確表示您的意圖是使用下一個字符n作爲換行符,而不是n字母。所以,使用\n

printf("Your gross salary is: %0.2f \n", GS); 
printf("The amount of your income tax is: %0.2f \n", Taxes); 
printf("Your net salary is: %0.2f \n", NS);