943,682 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 2276
  • C++ RSS
May 17th, 2008
0

Handling the space character?

Expand Post »
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.

C++ Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 25
Solved Threads: 4
Junior Poster
Black Magic is offline Offline
177 posts
since Apr 2008
May 17th, 2008
1

Re: Handling the space character?

replace line 11 with this
C++ Syntax (Toggle Plain Text)
  1. cin.getline(text,20)

hope that helps
Reputation Points: 19
Solved Threads: 20
Posting Whiz in Training
joshmo is offline Offline
280 posts
since Oct 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: _LINE_ in devc++
Next Thread in C++ Forum Timeline: Vista vs Microsoft Visual C++ 6.0





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


Follow us on Twitter


© 2011 DaniWeb® LLC