gpt4 book ai didi

c - 如何格式化/缩进多行文本常量

转载 作者:行者123 更新时间:2023-11-30 21:42:33 26 4
gpt4 key购买 nike

如何使用一个打印函数来打印第二行及后续行上具有正确代码缩进的所有文本?

    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");

最佳答案

您希望避免在字符串常量中使用 \[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");

关于c - 如何格式化/缩进多行文本常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40019650/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com