(compiled on Dev-C++)
Code:#include <stdio.h> #include <fstream> #include <iostream> #include <string.h> #include <windows.h> using namespace std; int main() { char str[]="good"; //Variable char input1; { cout<< "Hello, how are you today?\n"<< endl; getline(cin); char * pch; pch=strstr (input1, 'good'); //Searching for “good” in ^ Char str if(char str[] !=null) // or perhaps “zero” instead of “null”? or just “str” instead of whole tag… cout<< "I am glad to hear you are doing well today."<< endl; else cout<< "Is anything wrong at all? Would you like to discuss it? \n"<< endl; Sleep(50000); return 0; //END }
errors:
18 no matching function for call to `getline(std::istream&)'
21 [Warning] multi-character character constant
21 call of overloaded `strstr(char&, int)' is ambiguous
56 error candidates are: char* strstr(const char*, const char*) <near match>
125 char* std::strstr(char*, const char*) <near match>
24 syntax error before `!=' token
TY reRanger



LinkBack URL
About LinkBacks




Okay: I prefer C++ only and always. Although my instructor teaches mostly in C, I work in C++. (This is not a homework assignment, its self work, a snippet of a large project; if I depended on learning everything I needed to know here, I would never reach my goals I fear) Anyway, can you expalin to me my errors? A few others on here have been kind enough to mention their ideas and I have implemnted them (unfortunately, the comp lab I run at the school hates my Dev-C++ compiler, so I am coding blind until I get home.
But, hey, I appreciate your help, and I'm sure I will need more in the future.
jlou thank-you. I feeel like I get some of this a bit better now. I cannot wait to get home to my compiler. But before compiling, I think a rewrite of sorts is in order, just to start fresh and clean. Going to do that now...