printf 在行尾返回行长度
printf returning line length at end of line
每次打印 printf 语句时,行的长度都会被添加到末尾。例如:
cout << printf("%s", "foo") << endl;
cout << printf("%s", "foobar") << endl;
在我的控制台中显示:
foo3
foobar6
一个有趣的错误,有人知道它是什么吗?我正在使用 MinGW g++ 作为我的编译器。
声明
cout << printf("%s", "foo") << endl;
等同于
int res = printf("%s", "foo");
cout << res << endl;
printf
函数打印字符串,returns 打印字符数。然后 cout << ...
打印该整数值和换行符。
每次打印 printf 语句时,行的长度都会被添加到末尾。例如:
cout << printf("%s", "foo") << endl;
cout << printf("%s", "foobar") << endl;
在我的控制台中显示:
foo3
foobar6
一个有趣的错误,有人知道它是什么吗?我正在使用 MinGW g++ 作为我的编译器。
声明
cout << printf("%s", "foo") << endl;
等同于
int res = printf("%s", "foo");
cout << res << endl;
printf
函数打印字符串,returns 打印字符数。然后 cout << ...
打印该整数值和换行符。