+ 3
How to reply according to the user's input in Python and C++
Hello, guys, I need help with my application. I want to create an application that answers the user according to its input. For instance, it asks for the user's input and replies to it accordingly. If the user inputs "Hello", for example, the application replies "Hello User". I think, in the case of C++, I'd need to use the If function, but I'm not sure about how to do that.
8 Respuestas
+ 4
Thanks guy!
+ 3
Thanks. I'm a newbie at C++ programming, so...could you explain me that code?
+ 3
And how to do this: If the user inputs "Greeting", then the application replies with "This is a Greeting for you".
+ 3
Should I do it like this:
#include <stdfx.h>
#include <iostream>
#include <string>
int main(int argc, char *argv[]) {
string x;
cout << "Write something:" << endl;
cin >> x;
if (x = "Greeting")
{
cout << "This is a greeting for you";
}
Return 0;
}
+ 3
Thanks, that's why the compiller marked that as a Syntax Error.