2016-10-13 18 views
-6

2行目以降に正しいコードインデントを含むすべてのテキストを1つの印刷機能で印刷するにはどうすればよいですか?前に削除された答えからのコメントに示すように複数行テキスト定数の書式設定/インデント方法

printf("Program information\nThe program reads in the number of judges and \ 
the score from each judge.\nThen it calculates the average score without \ 
regard to the lowest and\nhighest judge score. Finally it prints the \ 
results (the highest, the \nlowest and the final average score).\n\n"); 
+1

あなたの例では、「正しく」とはどういう意味ですかhttp://ideone.com/wvEg5y –

+0

動作しますか?改行が機能しているはずです。意図する出力は何ですか? – Gernot

答えて

2

あなたは文字列定数内\[newline]を使用しないようにしたいです。

Cコンパイラはあなたのための文字列定数を連結しますので、あなたはこのようにそれをフォーマットすることができます。

printf("Program information\n" 
     "The program reads in the number of judges and the score from each judge.\n" 
     "Then it calculates the average score without regard to the lowest and\n" 
     "highest judge score. Finally it prints the results (the highest, the \n" 
     "lowest and the final average score).\n\n"); 
0

は、私はあなたがインデントのため\tたいと思います。

これは基本的な表作成機能です。

そのため、おそらく次のように:

printf("Program information\nThe program reads in the number of judges and \ 
the score from each judge.\n\tThen it calculates the average score without \ 
regard to the lowest and\n\thighest judge score. Finally it prints the \ 
results (the highest, the \n\tlowest and the final average score).\n\n"); 
関連する問題