Theillbehaviored

How do I make it so the user can type in a string in a console application and it will give a response For example if the user typed "Help" It would display a help file


Re: Visual C++ Language Comapring strings?

TilakGopi

Hi,

Use strcmp function to compare the input string with the valid string("Help") in ur case.

U need to include string.h header file.

Thanx,

Ch.T.Gopi Kumar.






Re: Visual C++ Language Comapring strings?

Simple Samples

It depends on whether you are using C style strings, standard C++ strings or CLI/CLR strings.

There are many answers to your questions and hundreds more that you will have in books and tutorials. You can use those resources, since people here have limited time available to answer questions.






Re: Visual C++ Language Comapring strings?

Simple Samples

TilakGopi wrote:
Use strcmp function to compare the input string with the valid string("Help") in ur case.
When using a C++ standard string as in string("Help") there is the "==" operator that can be used instead of strcmp.




Re: Visual C++ Language Comapring strings?

Allaudeen_N_ff93ad

Hi Pal,

You can do it my comparing the input string with the String "Help" or something else.....

int val= strcmp(str1,str2); is the syntax for it

if the two strings are equal it returns 1 or else it returns 0;

You should include <string.h> for using this function...

see the string.h header file for more string functions