如何更改“\t”的长度? [英] How to change the length of "\t"?

查看:712
本文介绍了如何更改“\t”的长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




可以更改\t的长度。到8以外的数字。


std :: cout<< " \t";


谢谢,


Hi,

It is possible to change the length of "\t" to a number other than 8.

std::cout << "\t";

Thanks,
Peng

推荐答案

彭宇 < Pe ******* @ gmail.com在消息新闻中写道:ad ******************************* *** @ 59g2000h sb.googlegroups.com ...
"Peng Yu" <Pe*******@gmail.comwrote in message news:ad**********************************@59g2000h sb.googlegroups.com...




可以更改长度\ t到8以外的数字。


std :: cout<< " \t";


谢谢,


Hi,

It is possible to change the length of "\t" to a number other than 8.

std::cout << "\t";

Thanks,
Peng



''\如果使用ASCII编码,则t''是十进制值为9的字符。它与任何其他角色的大小相同。

" \t"是一个由两个字符组成的数组,''\''和0.

如果你将它写入文件并进行转储,你会看到它。

终端或打印机收到此字符时的作用不是C ++主题。咨询终端或打印机手册。

''\t'' is a character with the decimal value of 9 if the ASCII coding is used. It has the same size as any other character.
"\t" is an array of two characters, ''\t'' and 0.
If you write it to a file and make a dump, you will see it.
What a terminal or printer does when it receives this character is not a C++ topic. Consult you terminal or printer manual.


7月14日上午7:24,彭宇< PengYu ... @ gmail.comwrote:
On Jul 14, 7:24 am, Peng Yu <PengYu...@gmail.comwrote:

可以更改\t的长度除了8.
It is possible to change the length of "\t" to a number other than 8.


std :: cout<< " \t英寸;
std::cout << "\t";



\t的长度在任何符合要求的C ++

系统中最好是两个。这可以追溯到C的开头,并且是如此简单和基本,我发现一个

编译器会误解它几乎是不可思议的。


我系统上两个字节的值是9和0,这对于除了大型机之外的所有东西几乎都是通用的。 (

标准要求第二个字节为0.然而,在IBM大型机上,第一个字节将是/ b $ b,但是,


那么你的8来自哪里?


-

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

Conseils eninformatiqueorientéeobjet/

Beratung in objektorientierter Datenverarbeitung

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

The length of "\t" had better be two on any conforming C++
system. This goes back to the very beginnings of C, and is so
simple and basic that I find it almost inconceivable that a
compiler would get it wrong.

The value of the two bytes on my systems are 9 and 0, which is
almost universal today on everything but mainframes. (The
standard requires the second byte to be 0. The first byte will
be 5, however, on an IBM mainframe.)

So where is your 8 coming from?

--
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


Peng Yu写道:
Peng Yu wrote:

Hi,


可以更改\t的长度。到8以外的数字。


std :: cout<< " \t";
Hi,

It is possible to change the length of "\t" to a number other than 8.

std::cout << "\t";



亲爱的彭,


''\ t''是一个字符(标签) ),根据你正在使用的观众,这个角色的格式改变了

,这不是

语言的问题。在控制台上打印它通常可以看到多个

空格,这些空格与下一列可以被8整除,但是这个

很容易改变,没有标准或者保证。如果你想要格式正确的输出,你宁可依赖空格,那就是:


cout<< "你好," << endl;

cout<< " !世界" <<结束;


Best,


Zeppe

Dear Peng,

''\t'' is a character (tab), and the formatting of this character changes
according to the viewer you are using, it''s not a problem of the
language. Printed on console it usually visualised with a number of
spaces that align to the next column which is divisible by 8, but this
can easily change and there is no standard or guarantee on that. If you
want properly formatted output, you''d rather rely on white spaces, that is:

cout << " hello," << endl;
cout << " world!" << endl;

Best,

Zeppe


这篇关于如何更改“\t”的长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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