Substring hunt and gather
A preview of some code I would like a response upon if possible: The mission: locate a word (substring) in user-input string and then have the ability to, in a sense, I guess, turn it into a function, triggering an event. Yes, it is simple, but I've yet to reach the point of it fully working as I picture it should. I determined that I could just use an event, in this case the return of null (or actually, a "!=null") to stage the next portion of the code. I am not looking for a complete fix (and please understand, I am at school working in a comp. lab where my Dev++ compiler will not run, so I am coding blind, and the code is set rather sloppy still-- no proper formatting) Just let me know what you think or where I could use some corrections. Is this substring function even doable as I have planned?
Cheers, reRanger
Code:
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <windows.h>
using namespace std;
int main()
{
Char str[ ]= “good”; //Variable
String input1[ ]
std::cout<< “Hello, how are you today?\n”<< endl;
getline(cin, input1, ‘\n’);
Char * pch;
pch=strstr (str, “good”); //Searching for “good” in ^ Char str
if
(char str[ ] !=null) // or perhaps “zero” instead of “null”? or just “str” instead of whole tag…
std::cout<< “I am glad to hear you are doing well today.\n”<< endl;
else
std::cout<< “Is anything wrong at all? Would you like to discuss it? \n”<< endl;
return 0; //END
}