我正在尝试使用打印一些字符串,printf()
但它们是空终止有尾随换行符并且与格式混淆:
printf("The string \"%s\" was written onto the file \"%s\"", str, fname);
假设字符串包含"The Racing car."
并且文件名是"RandomText1.txt"
这样打印:
The string "The Racing car.
" was written onto the file "RandomText1.txt
"
但是我希望它只打印一行:
The string "The Racing car." was written onto the file "RandomText1.txt"
我知道我可以修改字符串以摆脱空终止符换行符,但如果可能的话,我想在不修改字符串的情况下实现此输出。
是否可以?