这是我的程序,我总是%在每个程序的输出结束时得到一个标志.例如,在以下程序的输出结束时,我得到:
name1 and name2: You will reach the top.%
Run Code Online (Sandbox Code Playgroud)
这是代码:
#include <stdio.h>
#define message_for(a, b) \
printf(#a " and " #b ": You will reach the top.'\0'")
int main() {
message_for(name1, name2);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
所述\0在所述字符串的末尾作为一个字符串终止子.你的程序应输出:
name1 and name2 : You will reach the top.'
Run Code Online (Sandbox Code Playgroud)
没有尾随换行符.因此,在Unix系统和OS/X上,shell提示符将立即出现在'.你的shell提示可能非常简单,并以a开头%.以下是终端屏幕的可能副本:
% ./myprogram
name1 and name2 : You will reach the top.'% _
Run Code Online (Sandbox Code Playgroud)
随着_站立闪烁的光标下一个命令输入.您应该始终在邮件末尾输出一个尾随换行符:
#include <stdio.h>
#define message_for(a, b) \
printf(#a " and " #b ": You will reach the top.\n")
int main(void) {
message_for(name1, name2);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编辑:你说你正在一个在线服务上运行该程序:很有可能在输出中添加一个尾随换行符来解决问题,否则它可能是这个平台的一个功能,可以准确显示程序输出结束的位置真的是.