在Linux下工作,我刚刚遇到了以下问题.(当然,有人会给我答案,但到目前为止,我没有找到任何简单明了的答案:)
/*compile with gcc -o out.x hello.c*/
#include<stdio.h>
int main()
{
printf("Hello World2\r\n");
printf("Hello World3\r\n ");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在Linux下运行以下代码给出两个字符串但结尾字符是不同的:第一个输出以0x0d结尾,而第二个以0x0d,0x0a结尾.
这是由编译器(GCC)完成的,如obj文件中所示:
Contents of section .rodata:
400610 01000200 48656c6c 6f20576f 726c6432 ....Hello World2
400620 0d004865 6c6c6f20 576f726c 64330d0a ..Hello World3..
400630 2000 .
Run Code Online (Sandbox Code Playgroud)
所以,问题是:
谢谢