question on c++ programing

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2009
Posts: 1
Reputation: Bhawana Pant is an unknown quantity at this point 
Solved Threads: 0
Bhawana Pant Bhawana Pant is offline Offline
Newbie Poster

question on c++ programing

 
0
  #1
Jan 30th, 2009
program to count the number of characters in any string excluding the blank space.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: question on c++ programing

 
1
  #2
Jan 30th, 2009
That's nice. Is there a question you'd like to ask now?
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 462
Reputation: Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough 
Solved Threads: 71
Sponsor
Agni's Avatar
Agni Agni is offline Offline
Posting Pro in Training

Re: question on c++ programing

 
0
  #3
Jan 30th, 2009
and your attempt is......
thanks
-chandra
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 17
Reputation: its.romi is an unknown quantity at this point 
Solved Threads: 1
its.romi its.romi is offline Offline
Newbie Poster

Re: question on c++ programing

 
0
  #4
Jan 30th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 6
Reputation: jtfrench is an unknown quantity at this point 
Solved Threads: 0
jtfrench jtfrench is offline Offline
Newbie Poster

Re: question on c++ programing

 
0
  #5
Jan 30th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 338
Reputation: cikara21 is an unknown quantity at this point 
Solved Threads: 66
cikara21's Avatar
cikara21 cikara21 is offline Offline
Posting Whiz

Re: question on c++ programing

 
0
  #6
Jan 30th, 2009
What's going on here?..
.:-cikara21-:.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: question on c++ programing

 
0
  #7
Jan 30th, 2009
  1. replace (mystring.begin(), mystring.end(), " ", "");
  2. cout << mystring.length() << endl; // what?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 30
Reputation: FrancisC07 is an unknown quantity at this point 
Solved Threads: 1
FrancisC07's Avatar
FrancisC07 FrancisC07 is offline Offline
Light Poster

Re: question on c++ programing

 
0
  #8
Jan 31st, 2009
i think you should use the strlen after you write the output code..
strlen is to count the number of characters..
"One more round and it's bottle to the ground"
-NOFX
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: question on c++ programing

 
1
  #9
Feb 1st, 2009
>strlen is to count the number of characters..
...in a C-style string.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 490 | Replies: 8
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC