C++ string content function help!?
-
trying to get the program to recognize different things in one string. and i want it to be in a function in a different class to be called to. Here is the code: #include <iostream> #include <fstream> #include <string> #include <sstream> #include <cstdlib> using namespace std; string input; bool strContains(const string inputStr, const string searchStr) { size_t contains; contains = inputStr.find(searchStr); if(contains != string::npos) return true; else return false; } class functions { public: static void test() { if(strContains(input, "go")) { printf ("True"); } else if(strContains(input, "Stay")) { printf ("False"); } } }; //Testing the string content use for calling other functions // and finding commands #include <iostream> #include <string> #include "function.cpp" using namespace std; int main() { functions p; string doing; string input; cout << "What shall we do sir?" << endl; cin >> doing; input = doing; if(strContains(input, ";")) { p.test(); } else cout << "False"; return 0; } I'm getting errors with the class function code. any ideas?
-
Answer:
What errors are you getting? Because when i compiled your code (click here to see: http://codepad.org/QzwYYBX9 ) i didnt get any errors
daviddiz... at Yahoo! Answers Visit the source
Related Q & A:
- How to split a string in C++?Best solution by Stack Overflow
- How to convert from string to char in C++?Best solution by Stack Overflow
- How to implement C callback function in Swift?Best solution by pr8x.com
- How to marshall a string in C?Best solution by Stack Overflow
- Domain function help?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.