Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
This is my first day in C++ class, online and I was given to do this and I made this story thing and I'm having a hard time with it outputting something if I say no and something if I say yes, like a choice, can you guys help me?
C#
#include <iostream>

#include <string>

int main()
{
    using namespace std;
    
    cont << "Hello there travler, what is your name?!" << endl;
        string name;
        cin >> name;
    cont << name << "Why, what a wonderful name! Say, would you like to go on a quest for me!?"
    char yes;
         no;
         cin >> no;
         cin >> yes;   
         string yes;
         string no;
    cont << yes << "Well that's wonderful, go down to the village on the east side of the lake and help the villagers from the manslaughtering goblins!" << endl;
    cont << no << "Well that's a shame be gone then I have things to get done!" << endl;
    return 0;
}

C++



What I have tried:

I tried messing with it as much as I can but nothing is working.
Posted
Updated 22-Sep-16 10:42am
Comments
jeron1 22-Sep-16 15:38pm    
Please get a book and study the syntax as other have suggested, start on a smaller scale, throwing random code here will not accomplish anything. In this case I take it that 'nothing is working' equates to it wont compile as 'cont' has no meaning.
Member 12753942 23-Sep-16 8:34am    
I'm asking a question that better people could know, I just honestly want to know how to make a choice output and input.

You have two choices.

sprite or cola

user inputs spirte
"here's your sprite"
user inputs cola
"Here's your cola"
user inputs literally anything else
"Here is your money back"
this is the best way I can explain it.
jeron1 23-Sep-16 10:06am    
And 'better' people do know, however this is very rudimentary stuff, stuff that you NEED to know before you can do much of anything. A book to study is really the only way to learn this stuff, as it should have decent explanations of syntax and examples of its usage. You certainly may have specific questions about things, which many people would be happy to assist you with. Posting somewhat blind attempts at code that you claim 'doesn't work' is not going to get you where you want to go.
Philippe Mori 23-Sep-16 12:32pm    
Either you were sleeping... Or you are trying something not yet shown in your course...

1 solution

Here is links to references books on C and C++ by the authors of the languages. Note than C is the ancestor of C++, so knowing C is always useful with C++.
The C Programming Language - Wikipedia, the free encyclopedia[^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^]

C++ Programing Language[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900