Help

Posts 1–15 of 16 · Page 1 of 2
Help
Hi,

I learn c++ right now, and need some help. I try to make a Programm called "IWife". And i can't make it because I need to learn how to make it kinda like this :

cout<<"Hallo im IWife...."<<endl;
cout<<"How are you"<<endl;
cin<< (Here what you type (like fine);
if ( fine )
cout<<"Thats good for you";
else
cout<<"Thats bad"<<endl;

It has to do that but i didnt learn how to do it I'm still learning
these kind of things you can find them easily by googling

by the way, i did it for you with a explanation (better then i would do at least)

Basic Input/Output

Thats about Inpu/Ouput (cout//cin), also explains strings, etc..

Edit: you will find eg's there too... easy to understand
Thanks for the fast reply but the code from the input didn't work :O
If you want help with coding make sure you use code tags [/CODE][/CODE] remove the / from first CODE. Second post full code not just the part you are having trouble with. I do not know if you were using namespace..etc so I will assume and pray that you did. There are many ways to do what you want but I will keep it simple and show you one way of doing it.

Code:
#include "stdafx.h" //remove if not using vs
#include <iostream>

int main()
{
	int x;
	std::cout << "Please pick how you feel today." << std::endl;
	std::cout << "1.Fine 2.Good 3.Decent 4.Bad 5.Depressed 6.Other 7.IDK" << std::endl;
	std::cin >> x;
	
	if (x == 1)
	{
		std::cout << "stuff" << std::endl;
	}
	else if (x == 2)
	{
		std::cout << "stuff" << std::endl;
	}
        //move else ifs here etc
	else 
	{
		std::cout << "Sorry I don't believe you picked a correct option." << std::endl;
	}
}
Ok thank you for your answer but it doesnt work

It shows this line red cout << "Wie fühlst du dich heute?" << endl;

Code:
//IWife made by Matthew Stahlke

#inlcude <iostream>
using namespace std;

int main()
{
    int x;
    cout << "Wie fühlst du dich heute?" << endl;
    cin >> x;
    
    if (x == gut)
    {
          cout << "Das finde ich sehr gut." << endl;
    }
    else if (x == sehr gut)
    {
         cout << "Das finde ich super." << endl;
    }
    else
    {
        cout << "Mmh, das ist ziemlich dumm." << endl;
    }
}
Quote Originally Posted by Applesouce View Post
Ok thank you for your answer but it doesnt work

It shows this line red cout << "Wie fühlst du dich heute?" << endl;

Code:
//IWife made by Matthew Stahlke

#inlcude <iostream>
using namespace std;

int main()
{
    int x;
    cout << "Wie fühlst du dich heute?" << endl;
    cin >> x;
    
    if (x == gut)
    {
          cout << "Das finde ich sehr gut." << endl;
    }
    else if (x == sehr gut)
    {
         cout << "Das finde ich super." << endl;
    }
    else
    {
        cout << "Mmh, das ist ziemlich dumm." << endl;
    }
}
am i worng or are you comparing a int (number) with a "String"? also.. when you try to write something on that int x.. it will obviously crash, because you can't save a string on a int type.

(the link i gave you before talks about that, you should check it)

but keep working
Id give up on coding or start all over. You clearly do not understand the basic input and output so you are better off starting over. Go to your local library, book store, e book website and get a good c++ book id go with sams teach yourself c++ in 21 days. Read it cover to cover do not skip pages even if you think you understand what it is talking about.
Quote Originally Posted by valkmax View Post
Id give up on coding or start all over. You clearly do not understand the basic input and output so you are better off starting over. Go to your local library, book store, e book website and get a good c++ book id go with sams teach yourself c++ in 21 days. Read it cover to cover do not skip pages even if you think you understand what it is talking about.
he just started.. oO it's normal that people sometimes "fail" at this type of things... it would be stupid if he was trying to do a cicle or somethig without knowing this... but he is just doing the basic after hello world... t.t
Quote Originally Posted by valkmax View Post
Id give up on coding or start all over. You clearly do not understand the basic input and output so you are better off starting over. Go to your local library, book store, e book website and get a good c++ book id go with sams teach yourself c++ in 21 days. Read it cover to cover do not skip pages even if you think you understand what it is talking about.
I agree if you just start with the first chapter of almost any course the first thing you learn is that an integer is a number an not characters...
so just go read a tutorial.

first learn then practice
Thank you very much for beliving in me I really just startet ^^ I made the "Hello world" on the same day xD but I will not give up learning c++

Quote Originally Posted by 'Bruno View Post
he just started.. oO it's normal that people sometimes "fail" at this type of things... it would be stupid if he was trying to do a cicle or somethig without knowing this... but he is just doing the basic after hello world... t.t
Yeh. Give him a chance. He's obviously not use to the language (C++, ur english is fine).

You will have to use a char* type variable for the cin and cout statements. that of an array of char (characters)
Code:
char str[50]; // this would create an array of 50 chars
Also try returning 1 at the end of ur main() function.
@Brinuz
@why06
Please reread my post and you will see I said give up OR restart from stretch. Why? Because he does not understand input and output and types. These are always first thing such as the hello world program. Some people rereading things helps allot.
Quote Originally Posted by valkmax View Post
@Brinuz
@why06
Please reread my post and you will see I said give up OR restart from stretch. Why? Because he does not understand input and output and types. These are always first thing such as the hello world program. Some people rereading things helps allot.
and i advice you to re read too because that's the start... input/output... what do you want him to start with? :\
Quote Originally Posted by 'Bruno View Post
and i advice you to re read too because that's the start... input/output... what do you want him to start with? :\
Yeh. Haha... I have to agree with that. Not much to go back to considering he's starting at square one. lol... Im noot sure what you would call "Hello World" but this looks like it to me.
He is trying to use if statements, variables, and much more. Granted I added else if but he was already trying with using if statement. So I think he needs to go back and get a working hello world before adding variables.
Posts 1–15 of 16 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?