C++制表符"\t”的用法
#include<iostream>intmain(){std::cout<<"Thesizeofashortintis:\t"<<sizeof(shortint)<<"...
#include <iostream>
int main()
{
std::cout << "The size of a short int is:\t" << sizeof(short int) <<"\n";
std::cout << "The size of an int is:\t" << sizeof(int) << "\n";
std::cout << "The size of a long int is:\t" << sizeof(long int) << "\n";
std::cout << "The size of a char is:\t" << sizeof(char) << "\n";
std::cout << "The size of a float is:\t" << sizeof(float) << "\n";
std::cout << "The size of a double is:\t" << sizeof(double) << "\n";
std::cout << "The size of a bool is:\t" << sizeof(bool) << "\n";
return 0;
}
显示出来却是:
The size of a short int is: 2
The size of an int is: 4
The size of a long int is: 4
The size of a char is: 1
The size of a float is: 4
The size of a double is: 8
The size of a bool is: 1
Press any key to continue
制表符没起作用吗? 展开
int main()
{
std::cout << "The size of a short int is:\t" << sizeof(short int) <<"\n";
std::cout << "The size of an int is:\t" << sizeof(int) << "\n";
std::cout << "The size of a long int is:\t" << sizeof(long int) << "\n";
std::cout << "The size of a char is:\t" << sizeof(char) << "\n";
std::cout << "The size of a float is:\t" << sizeof(float) << "\n";
std::cout << "The size of a double is:\t" << sizeof(double) << "\n";
std::cout << "The size of a bool is:\t" << sizeof(bool) << "\n";
return 0;
}
显示出来却是:
The size of a short int is: 2
The size of an int is: 4
The size of a long int is: 4
The size of a char is: 1
The size of a float is: 4
The size of a double is: 8
The size of a bool is: 1
Press any key to continue
制表符没起作用吗? 展开
4个回答
展开全部
制表符表示的是,从行首开始,每8字节算一个制表位(也就是4个英文字符),'\t'会在当前内容结束后第一个空的制表位处接上下文。
无猜你是想对齐后面的数字,但是制表符没有强制对齐的功能的,这样的话你不得不数一数你两句话之间差了几个制表位了。比如第一句第二句就差了两个制表位。
无猜你是想对齐后面的数字,但是制表符没有强制对齐的功能的,这样的话你不得不数一数你两句话之间差了几个制表位了。比如第一句第二句就差了两个制表位。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
哈哈
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询