Well my problem is I want to type "What is the word" in the console and have it "say the bird is the word:" I know how to keep it going and make a exit so to speak but how the hell do I make it do that ? I know the code is all jacked up but I need the help
#include <iostream>
using namespace std;
int main()
{
beg:
string mystring;
char crack[] = "The Bird Is The Word";
mystring = crack;
what you want to do is call getline() with cin as a parameter. You want to then make sure the string is equivalent to "What is the word". Then you can proceed with your loop.
if you just shift in from cin you'll get a word at a time, and whitespace will be ignored.
If you want to get a full sentence from user input, you must use cin.getline function. Here is an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// istream::getline example
#include <iostream> // std::cin, std::cout
int main () {
char name[256], title[256];
std::cout << "Please, enter your name: ";
std::cin.getline (name,256);
std::cout << "Please, enter your favourite movie: ";
std::cin.getline (title,256);
std::cout << name << "'s favourite movie is " << title;
return 0;
}
This is the same thing as other things I have looked at I want to know in code how to type in the console say "what is the word" then it responds back saying "the bird is the word" and then I can go back and say type what is your power level and then it responds "over 9000 ! " in code you are basically telling me if I type in my name it retrieves it and then says my name and so in so is my favorite movie that is not what I am trying to do
It's really not that big of a conceptual leap to go from aleonard's example to what you want. Just write a while loop, and in the loop use getline() and then have a bunch of if and elseif statements to do string comparisons and write the appropriate result to cout.