Handling the space character?

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2008
Posts: 177
Reputation: Black Magic is an unknown quantity at this point 
Solved Threads: 4
Black Magic's Avatar
Black Magic Black Magic is offline Offline
Junior Poster

Handling the space character?

 
0
  #1
May 17th, 2008
Hey, I made i looked up toupper and made a little program out of it and have come to a little situation, When i enter the space character " " it does not output what i want and it just closes.

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int i = 0;
  8. char text[20];
  9.  
  10. cout << "Enter A Word (Letters Must All Be Lower Case) : ";
  11. cin >> text;
  12.  
  13. while(text[i])
  14. {
  15. putchar (toupper(text[i]));
  16. i++;
  17. }
  18.  
  19.  
  20. cin.get();
  21. cin.get();
  22.  
  23. return 0;
  24. }

Thank you in advance.
C Plus Plus Coder.
Fourteen Years Of Age
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 280
Reputation: joshmo is an unknown quantity at this point 
Solved Threads: 19
joshmo joshmo is offline Offline
Posting Whiz in Training

Re: Handling the space character?

 
1
  #2
May 17th, 2008
replace line 11 with this
  1. cin.getline(text,20)

hope that helps
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1604 | Replies: 1
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC