PirateKing15

n00b C++ program

9 posts in this topic

im trying to learn c++ and i am having a little trouble understanding things.

any help at all would be usefull. i made a small practice program and it wont compile. I'm using DevC++ compiler and and

i keep getting the same error:

32:2 C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. 

can someone help with that and there are other errors that i can fix. here is the code:

// Random Conversation Bot

#include <iostream.h>
using namespace std;

int main();
{
cout << "Are you gay?\n";
cin >> r;
if r = "yes";
cout << "HAHAHA!!! Your Gay.\n";
if r = "no"
cout << "Does your mamma know your gay?\n";
cin >> e;
if e = "yes";
cout << "HAHAHA!!! Your Gay.\n";
if e = "no";
cout << "HAHAHA!!! Your Gay.\n";
getchar();
return 0;
}

any suggestions would help. THX

EDIT:

i took tiocsti's info and modified the code and i keep gettingh only 2 errors so it wont compile. The new code is:

// Random Conversation Bot

#include <iostream>
using namespace std;

int main();
{
string In_1;
string In_2;
cout << "Are you gay?\n";
cin >> In_1;
if In_1 == "yes";
cout << "HAHAHA!!! Your Gay.\n";
if In_1 == "no"
cout << "Does your mamma know your gay?\n";
cin >> In_2;
if In_2 == "yes";
cout << "HAHAHA!!! Your Gay.\n";
if In_2 == "no";
cout << "HAHAHA!!! Your Gay.\n";
getchar();
return 0;
}

The errors are:

7 C:\Documents and Settings\Joshua\Desktop\funny.cpp expected unqualified-id before '{' token

and

7 C:\Documents and Settings\Joshua\Desktop\funny.cpp expected `,' or `;' before '{' token

Both of them are in line 7.

PLZ help if you can

Edited by L33T_j0sH
0

Share this post


Link to post
Share on other sites

k thx

that helps alot

and i only learned a little bit of python, but i see what you mean.

0

Share this post


Link to post
Share on other sites

No ; after a function header, unless you want it to be a prototype.

int main()
{
return 0;
}

0

Share this post


Link to post
Share on other sites
// Random Conversation Bot

#include <iostream>
// #include <string> (http://www.planetcpp.info/chapter4.html#std::strings)
using namespace std;

int main(); // like he said, you dont want a ; here
{
string In_1;
string In_2;
cout << "Are you gay?\n";
cin >> In_1;
if In_1 == "yes";
cout << "HAHAHA!!! Your Gay.\n";
if In_1 == "no"
cout << "Does your mamma know your gay?\n";
cin >> In_2; // this line and below is going to happen no matter what unless you add a { after your second if
if In_2 == "yes";
cout << "HAHAHA!!! Your Gay.\n";
if In_2 == "no"; //use else if, no point in checking a second time (http://www.planetcpp.info/chapter3.html#The_else_if_Statement)
cout << "HAHAHA!!! Your Gay.\n";
// you dont handle if its not one of the two above cases

getchar();
return 0;
//this program is, like any other childish name calling, lame. You probably really could get more help if you didnt talk like a 5th grader.
}

0

Share this post


Link to post
Share on other sites

yeah, you right about the childish thing. (SRY) i was thinking about a simple program to test my C++ so far and that popped into my head. didn't mean to sound childish. and thanks for the hewpl also. i wont make a stupid program like that next time i start a new one.

THX

0

Share this post


Link to post
Share on other sites

If you are gonna write stuff like that why not use VBs. You don't even need a compiler, and its extremely easy.

Or are just wanting to learn C++ for the heck of it?

Edited by Demonic_angel
0

Share this post


Link to post
Share on other sites

Why learn VB? C++ is a good language that will work on multiple OSs

0

Share this post


Link to post
Share on other sites

zal is right. it is a good and universal language. plus i started learning it a while back and stopped so i want to finish what i started.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now