Counting whitespaces in a string

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 521 Views - Last Post: 04 February 2013 - 06:57 AM Rate Topic: -----

#16 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2836
  • View blog
  • Posts: 9,741
  • Joined: 08-August 08

Re: Counting whitespaces in a string

Posted 03 February 2013 - 03:20 PM

That's a C++ string. They're different from C strings. Which language are you required to use?
Was This Post Helpful? 0
  • +
  • -

#17 SplinteredChaos  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 112
  • Joined: 15-September 11

Re: Counting whitespaces in a string

Posted 03 February 2013 - 11:16 PM

@CT, it is a C++ programming class, so C++.
Was This Post Helpful? 0
  • +
  • -

#18 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 710
  • View blog
  • Posts: 2,033
  • Joined: 20-March 10

Re: Counting whitespaces in a string

Posted 04 February 2013 - 01:32 AM

View PostSplinteredChaos, on 03 February 2013 - 10:08 PM, said:

 string adPhrase;
is how I have adPhrase declared at this point. Is that not correct?


Yes that is correct

but you cant use cin as it reads up to the whitespace
and no further , you will need to use getline to ehmm get a line...

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#19 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2836
  • View blog
  • Posts: 9,741
  • Joined: 08-August 08

Re: Counting whitespaces in a string

Posted 04 February 2013 - 06:57 AM

View PostSplinteredChaos, on 04 February 2013 - 02:16 AM, said:

@CT, it is a C++ programming class, so C++.

Then don't use char. Use string and the methods it has available:
http://www.cplusplus.../string/string/
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2