Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Apr 30th, 2008, 5:45 PM   #11
Freaky Chris
Hobbyist Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 169
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
Re: multiple values for one char

Indeed there is, im not thinking straight as im falling asleep but anyway you could use something like this.

C++ Syntax (Toggle Plain Text)
  1. #include <cctype>
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. string stripcase(string instring){
  7. string buffer = "";
  8. for(int i = 0; i < instring.length(); i++){
  9. buffer += tolower(instring[i]);
  10. }
  11. return buffer;
  12. }
  13.  
  14. int main()
  15. {
  16. string input1 = "winSton Chruchill"; //this would be set via user input of course, just an example
  17.  
  18. string correct1 [2] = {"Winston Churchill", "Chruchill"};
  19.  
  20. for(int i = 0; i < 2; i++)
  21. {
  22. if(stripcase(correct1[i]) == stripcase(input1)){
  23. cout << "Congratulations, you got it!";
  24. }
  25. }
  26.  
  27. return 0;
  28. )

Something like that is what your after, there are probably better ways but i cannot thing straight right now, im gonna shoot off anyway so if you need it explaining then im sure one of the other guys will help. If not i will when im next online.

I recomment reading up on cctype as this will help you understand what is going on, also you should be aware that you are able to treat strings as char arrays, these will help you understand this.

C++ Syntax (Toggle Plain Text)
  1. buffer += tolower(instring[i]);

Cheers,
Chris
__________________
Who said i couldn't program
sarcasm = raw_input('Type in a sarcastic remark: ')
print sarcasm
Freaky Chris is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem processing file into a char array csrocker101 C++ 1 May 8th, 2007 11:50 PM
Convert char[14] to char * myName C++ 1 Mar 5th, 2006 8:08 PM