检查行是否为空格 [英] check if line is whitespace
问题描述
检查以下内容的最快方法是什么:
const line [127];只包含空格,在这种情况下忽略它。
这些内容:
isspacedLine(line);
谢谢
What is the quickest way to check that the following:
const line[127]; only contains whitespace, in which case to ignore it.
something along these lines:
isspacedLine(line);
Thanks
推荐答案
puzzlecracker写道:
puzzlecracker wrote:
什么是检查以下内容的最快方法:
const line [127];只包含空格,在这种情况下忽略它。
这些内容:
isspacedLine(line);
What is the quickest way to check that the following:
const line[127]; only contains whitespace, in which case to ignore it.
something along these lines:
isspacedLine(line);
const line [127];
在c ++中没有任何意义。除此之外,如果line是一个
char的数组,我非常肯定有人带着puzzlecracker。作为
昵称将能够解决它;)
祝福,
Zeppe
const line[127];
doesn''t mean anything in c++. Apart from that, if line is an array of
char, I''m pretty much sure that somebody with "puzzlecracker" as
nickname will be more than able to solve it ;)
Best wishes,
Zeppe
2008年9月3日星期三10:21:58 -0700,puzzlecracker写道:
On Wed, 03 Sep 2008 10:21:58 -0700, puzzlecracker wrote:
检查以下内容的最快方法是什么:
const line [127];只包含空格,在这种情况下忽略它。
这些内容:
isspacedLine(line);
< br $>
谢谢
What is the quickest way to check that the following:
const line[127]; only contains whitespace, in which case to ignore it.
something along these lines:
isspacedLine(line);
Thanks
假设您正在尝试读取127个字符宽的输入行......我还要b
认为const char line [127]提到...
用getline()读取并检查
字符串类的空()函数是否为空。
// string :: empty
#include< iostream>
#include< string>
using namespace std;
int main()
{
字符串内容;
字符串行;
cout<< 请介绍一下。输入一个空行完成:\ n" ;;
do {
getline(cin,line);
content + = line + ''\ n'';
} while(!line.empty());
cout<< 你介绍的文字是:\ n <<内容;
返回0;
}
HTH,
supposing you are trying to read some input lines of 127 char wide... I
also think that "const char line[127]" is mentioned...
Read with getline() and check if empty with empty() function of the
string class.
// string::empty
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string content;
string line;
cout << "Please introduce a text. Enter an empty line to finish:\n";
do {
getline(cin,line);
content += line + ''\n'';
} while (!line.empty());
cout << "The text you introduced was:\n" << content;
return 0;
}
HTH,
2008年9月3日星期三19:43:50 + 0200,utab写道:
On Wed, 03 Sep 2008 19:43:50 +0200, utab wrote:
2008年9月3日星期三,星期三,晚上10:21:58 -0700,puzzlecracker写道:
On Wed, 03 Sep 2008 10:21:58 -0700, puzzlecracker wrote:
>检查以下内容的最快方法是什么:
const line [127];只包含空格,在这种情况下忽略它。
这些内容:
isspacedLine(line);
谢谢
>What is the quickest way to check that the following:
const line[127]; only contains whitespace, in which case to ignore it.
something along these lines:
isspacedLine(line);
Thanks
假设您正在尝试读取一些127个字符宽的输入行......我或者b $ b也认为const char line [127]被提到...
supposing you are trying to read some input lines of 127 char wide... I
also think that "const char line[127]" is mentioned...
当然使用getline const char ...是错误的。
Of course with getline const char ... is wrong.
这篇关于检查行是否为空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!