很多文字,一个cout<< ? [英] much text, one cout<< ?

查看:139
本文介绍了很多文字,一个cout<< ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是否会导致我的便携性问题?

目的:让我可以轻松地在.cpp文件中编写帮助文本块,

就像我希望它根据需要输出''formatted-ly''而

程序正在运行。


#include < iostream> ;;

使用命名空间std;


int main(){

cout<<"这些\\ \\ / $
行数\ n \

是\

多少\

更长\ nn \\ b
比\

this.\\\
" ;;


返回0;

}


(或者,更好的建议,没有更多的代码?)

谢谢

-

Peace

JB
jb@tetrahedraverse.com

网址:< a rel =nofollowhref =http://tetrahedraverse.comtarget =_ blank> http://tetrahedraverse.com

解决方案

John Brawley写道:


这会导致我的便携性问题吗?



这是无效的C ++,所以,是的,你打赌。


目的:制作我很容易在

.cpp文件中编写我的帮助文本块,就像我希望它向用户输出''formatted-ly''一样
程序运行时需要


#include< iostream> ;;

使用命名空间std;


int main(){

cout<<"这些\

行数\ n \

是\\ /

多了\

更长$ \\ n \

比\

this.\ n" ;;


返回0;

}


(或者,更好的建议,没有更多代码? )

谢谢



用双引号括起每一行文字。


V

-

请在通过电子邮件回复时删除资金''A'

我没有回复最热门的回复请不要问


在2008-02-09 19:15,John Brawley写道:


这会导致我的便携性问题吗?

目的:让我可以轻松地在.cpp文件中编写''help''文本块,

就像我希望它根据需要输出''formatted-ly''而

程序正在运行。


#include < iostream> ;;

使用命名空间std;


int main(){

cout<<"这些\\ \\ / $
行数\ n \

是\

多少\

更长\ nn \\ b
比\

this.\\\
" ;;


返回0;

}


(或者,更好的建议,没有更多的代码?)



如果你有一些字符串文字后彼此编译时会将它们联系起来,只需写eac h用双引号括起来:


#include< iostream>


int main()

{

std :: cout<<

"这里开始一个数字

" of long lines" ;;

}

不要忘记在任何需要的地方添加换行符(\ n)。


-

Erik Wikstr ?? m


2月9日晚上8:32,Victor Bazarov < v.Abaza ... @ comAcast.netwrote:


John Brawley写道:


Is这会导致我的便携性问题吗?


这是无效的C ++,所以,是的,你打赌。



它有什么问题?它不是很好的C ++,但它看起来很合理。

我。


目的:制作我很容易在.cpp文件中写下''help''文本块

,就像我希望它输出一样

''formatated-ly' '当程序运行时,按需要向用户提供


#include< iostream> ;;

using namespace std ;


int main(){

cout<<" ;这些\

行数\ n \

是\

很多\

更长\\ n \

比\

this.\\\
" ;;


return 0;

}


(或者,更好的建议,没有更多的代码?)


用双引号括起每一行文字。



这将使代码更具可读性(因为以下

行可以正确缩进),但不会改变任何内容

代码的含义。


-

James Kanze(GABI Software)电子邮件:ja ***** **** @ gmail.com

Conseils eninformatiqueorientéeobjet/

Beratung in objektorientierter Datenverarbeitung

9placeSémard,78210 St.- Cyr-l''école,法国,+ 33(0)1 30 23 00 34


Is this going to cause me a portability problem?
Purpose: make it easy for me to write my ''help'' text block in the .cpp file,
just as I wish it to be output ''formatted-ly'' to the user upon demand while
the program is running.

#include <iostream>;
using namespace std;

int main() {
cout<<"these \
lines\n\
are \
much \
longer\n\
than \
this.\n";

return 0;
}

(Or, any better suggestion, without more code?)
Thanks
--
Peace
JB
jb@tetrahedraverse.com
Web: http://tetrahedraverse.com

解决方案

John Brawley wrote:

Is this going to cause me a portability problem?

It''s not valid C++, so, yes, you bet.

Purpose: make it easy for me to write my ''help'' text block in the
.cpp file, just as I wish it to be output ''formatted-ly'' to the user
upon demand while the program is running.

#include <iostream>;
using namespace std;

int main() {
cout<<"these \
lines\n\
are \
much \
longer\n\
than \
this.\n";

return 0;
}

(Or, any better suggestion, without more code?)
Thanks

Surround every line of text with double quotes.

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


On 2008-02-09 19:15, John Brawley wrote:

Is this going to cause me a portability problem?
Purpose: make it easy for me to write my ''help'' text block in the .cpp file,
just as I wish it to be output ''formatted-ly'' to the user upon demand while
the program is running.

#include <iostream>;
using namespace std;

int main() {
cout<<"these \
lines\n\
are \
much \
longer\n\
than \
this.\n";

return 0;
}

(Or, any better suggestion, without more code?)

If you have a number of string literals after each other they will be
concatenated when compiling, just write each line enclosed by double quotes:

#include <iostream>

int main()
{
std::cout <<
"Here begins a number "
"of long lines";
}
Do not forget adding newlines (\n) wherever you need one.

--
Erik Wikstr??m


On Feb 9, 8:32 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:

John Brawley wrote:

Is this going to cause me a portability problem?

It''s not valid C++, so, yes, you bet.

What''s wrong with it? It''s not good C++, but it looks legal to
me.

Purpose: make it easy for me to write my ''help'' text block
in the .cpp file, just as I wish it to be output
''formatted-ly'' to the user upon demand while the program is
running.

#include <iostream>;
using namespace std;

int main() {
cout<<"these \
lines\n\
are \
much \
longer\n\
than \
this.\n";

return 0;
}

(Or, any better suggestion, without more code?)

Surround every line of text with double quotes.

Which will make the code more readable (since the following
lines can be correctly indented), but won''t change anything in
the meaning of the code.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l''école, France, +33 (0)1 30 23 00 34


这篇关于很多文字,一个cout&lt;&lt; ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆