| | |
C++ problem
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
There are a couple approaches in c++ language:
1) if input is in the form of a std::string object, you can use it's find() method to determine if it contains any of the words, example:
2) The other way, using standard C style character arrays
Now if course you will have to change the above to check each of the words listed in your assignment, as well as all the other requirements which I did not mention.
And don't forget to include the appropriage header files.
1) if input is in the form of a std::string object, you can use it's find() method to determine if it contains any of the words, example:
C++ Syntax (Toggle Plain Text)
std::string input; cout << "Enter a word\n"; cin >> input; if( input.find("ONE") != std::npos) { // found it. }
2) The other way, using standard C style character arrays
C++ Syntax (Toggle Plain Text)
char input[20]; cout << "Enter word\n"; cin >> input; if( strstr(input,"ONE") != NULL) { // found it }
Now if course you will have to change the above to check each of the words listed in your assignment, as well as all the other requirements which I did not mention.
And don't forget to include the appropriage header files.
Last edited by Ancient Dragon; Nov 30th, 2008 at 12:36 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Jun 2008
Posts: 182
Reputation:
Solved Threads: 18
•
•
•
•
I will remember you forever!
Ancient Dragon already gave you a start. I'm feeling to give you just some general advices:
1 - Divide your program in steps - most common are input, processing and output but you can elaborate this further
2 - Write one step at a time, for example begin with a program that only accepts one string input and quits. Then try to solve the problem for simplest cases (i.e. the user enters "one" or "nine").
3 - Post your code. We will gladly help you (not for the glory, however) if you show us you do care enough. When I ask for help I think that the time of people more expert than me is more precious than mine. Consequently, I have to devote more time than they do in solving my problem. If I don't act this way, I won't learn anything. Try to think this way and you'll be surely helped.
Regards
![]() |
Similar Threads
- Problem with Windows Update and WinXP (Web Browsers)
- Installing Windows 98 On VMware. Floppy problem (Windows 95 / 98 / Me)
- Windows XP keeps restarting since a new video card (Windows NT / 2000 / XP)
- Redhat Linux 6.2 - ipop3d problem? (*nix Software)
- Problem with T720 (Cellphones, PDAs and Handheld Devices)
- Connection Problems (Networking Hardware Configuration)
- Encoding (Unicode) problem in IE 6.0 (Web Browsers)
- .htaccess mod_rewrite problem (Linux Servers and Apache)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
Other Threads in the C++ Forum
- Previous Thread: How do you block certian inputs.
- Next Thread: What is The Difference Between CSocket() and socket()? Questions About MFC Wrappers
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile console conversion convert count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game generator givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






