943,779 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 753
  • C++ RSS
Jan 30th, 2009
0

question on c++ programing

Expand Post »
program to count the number of characters in any string excluding the blank space.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Bhawana Pant is offline Offline
1 posts
since Jan 2009
Jan 30th, 2009
1

Re: question on c++ programing

That's nice. Is there a question you'd like to ask now?
Team Colleague
Reputation Points: 2240
Solved Threads: 338
Vampirical Lurker
John A is offline Offline
5,055 posts
since Apr 2006
Jan 30th, 2009
0

Re: question on c++ programing

and your attempt is......
Featured Poster
Reputation Points: 431
Solved Threads: 116
Practically a Master Poster
Agni is offline Offline
654 posts
since Dec 2007
Jan 30th, 2009
0

Re: question on c++ programing

create a pointer and use increament operator to read the string. This should be maintained in a loop till the end of string. And for every next character make a check using if(*ptr == ' ') then your counter, which counts the number of words, should not increase.
Reputation Points: 8
Solved Threads: 1
Newbie Poster
its.romi is offline Offline
17 posts
since Dec 2007
Jan 30th, 2009
0

Re: question on c++ programing

This is pretty simple. Just take your string (which depending on how your using strings, will be a char* or an std::string), and iterate through each char until you reach the '\n' new line character.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jtfrench is offline Offline
6 posts
since Jan 2009
Jan 30th, 2009
0

Re: question on c++ programing

What's going on here?..
Reputation Points: 47
Solved Threads: 69
Posting Whiz
cikara21 is offline Offline
340 posts
since Jul 2008
Jan 30th, 2009
0

Re: question on c++ programing

C++ Syntax (Toggle Plain Text)
  1. replace (mystring.begin(), mystring.end(), " ", "");
  2. cout << mystring.length() << endl; // what?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 31st, 2009
0

Re: question on c++ programing

i think you should use the strlen after you write the output code..
strlen is to count the number of characters..
Reputation Points: 10
Solved Threads: 2
Light Poster
FrancisC07 is offline Offline
30 posts
since Feb 2008
Feb 1st, 2009
1

Re: question on c++ programing

>strlen is to count the number of characters..
...in a C-style string.
Team Colleague
Reputation Points: 2240
Solved Threads: 338
Vampirical Lurker
John A is offline Offline
5,055 posts
since Apr 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: strange signs server->client connection with select()
Next Thread in C++ Forum Timeline: system("cls")





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC