>plz may u put that in english lol ?!?!
English doesn't compile.
>i copy and pasted it and it said it had 9 errors!!
You probably didn't integrate the code properly (translation: You cut and pasted wrong). This is the code that works for me and should work for you as well.
Code:
#include <iostream.h>
#include <string.h>
void prompt1();
int prompt2();
void greeting();
int
main()
{
prompt1();
switch (prompt2()) {
case 1:
cout<<"Well? ";
greeting();
break;
case 2:
cout<<"Meanie"<<endl;
break;
default:
cout<<"Huh?"<<endl;
break;
}
char ch;
while (cin.get(ch) && ch != '\n') {
// Nothing goes here
}
cin.get();
return 0;
}
void
prompt1()
{
char answer[50];
cout<<"How are you? ";
cin.getline(answer, 50);
cout<<"You are: "<< answer <<endl;
}
int
prompt2()
{
int answer;
cout<<"Aren't you going to ask how I am?\n";
cout<<"1) Yes\n2) No\n: ";
cin>> answer;
cin.ignore();
return answer;
}
void
greeting()
{
char greeting[50];
cin.getline(greeting, 50);
if (strcmp(greeting, "How are you?") != 0) {
cout<<"You still haven't asked me how I am!"<<endl;
}
else {
cout<<"I'm fine, thank you."<<endl;
}
}
p.s. iostream.h is an antiquated header. If your compiler doesn't support the following program, I highly recommend you get a new compiler so that I don't have to keep dumbing down my code so that it'll compile for you.
Code:
#include <iostream>
using namespace std;
int
main()
{
cout<<"Hello, world!"<<endl;
}
If that program does compile and run, please start using the newer headers as just about everyone here will be giving you code in modern C++.