Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > check if line is whitespace

Reply
Thread Tools

check if line is whitespace

 
 
Jorgen Grahn
Guest
Posts: n/a
 
      09-08-2008
On Wed, 3 Sep 2008 10:21:58 -0700 (PDT), puzzlecracker <(E-Mail Removed)> wrote:
> 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);


Reformulate your problem to use std::string, and then:

/**
* True iff s is empty or only contains space and/or TABs.
*/
bool util::isblank(const std::string& s)
{
return s.find_first_not_of(" \t")==std::string::npos;
}

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se> R'lyeh wgah'nagl fhtagn!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Splitting text at whitespace but keeping the whitespace in thereturned list MRAB Python 3 01-26-2010 11:36 PM
Structure using whitespace vs logical whitespace cmdrrickhunter@yaho.com Python 10 12-16-2008 03:51 PM
Preprocessor directives must appear as the first non-whitespace character on a line IndyChris ASP .Net 1 08-09-2006 01:21 AM
Preprocessor directives must appear as the first non-whitespace character on a line erin.sebastian@cowaninsurancegroup.com ASP .Net 0 02-14-2006 03:11 PM
Whitespace where I don't want whitespace! Oli Filth HTML 9 01-17-2005 08:47 PM



Advertisments