Click here to Skip to main content
14,115,780 members
Rate this:
Please Sign up or sign in to vote.
See more:
How do I make a user like type in "I'm feeling good" and it reads the "good" part in which the program would respond to
"I see, That's great to hear from you"

My code is like when i type in "jasdhagood" or anything other than the 'good' itself would respond to blank.


User:I'm good
Program:I see, That's great to hear from you

Anyone, help me?

What I have tried:

#include <iostream>
#include <cstring>
#include <String>

using namespace std;

void replyy(){
	string y;
	cout<<"I see your name is "<<y<<endl;

void goodornot(){
char responds[50];
	cout<<"I see, That's great to hear from you";

else if(!strcasecmp("great",responds)){
	cout<<"I see, Feeling great!"<<endl;


int main(){
  char str[50];
  char understanding[50];
  char relation[50];
  if(strcasecmp ("hello",str)==0){
  cout<< "Doing good?";

 else if(!strcasecmp ("hi",str)){
cout<<"hey there what's your name"<<endl;


else if(!strcasecmp ("sad",str)){
cout<<"Don't be sad.'"<<understanding;
goto here;

return 0;
Updated 19-Jul-18 20:25pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

AnnoyingPig 20-Jul-18 1:20am
I see. Thank you for the information. Is it applicable with c++?
Gerry Schmitz 20-Jul-18 14:39pm
It's applicable to any (.NET) "managed" language: C#; VB.NET; C++; ...
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

What you want is to find some text into other text. Use the string::find functions. The string class has also other nice functions.

I would use case insenstive comparison.

Take care of compiler warnings, because the show you problems. Assigning a string to char buffer shouldnt work!!!
AnnoyingPig 20-Jul-18 13:36pm
:D okay, gonna study this now! Thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.190518.1 | Last Updated 20 Jul 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100