Jan 29, 2012 at 9:16pm UTC
HI
I have a small program with 3 files.
main.cpp
#include "head.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
loop:
string name;
cout << "what is your name " << endl;
getline (cin, name);
if (name == "mark")
next();
else;
cout << "invalid input " << endl;
goto loop;
}
next.cpp
#include <iostream>
#include <string>
#include "head.h"
using namespace std;
int next()
{
cout << "woo hoo I did it " << endl;
}
and head.h
#ifndef HEAD_H
#define HEAD_H
int next();
#endif
My problem is when I enter my name as mark the out put is
"woo hoo i did it"
"invalid input"
"what is your name"
I want the program to end after the call to next.cpp
Thanks
Last edited on Jan 29, 2012 at 9:28pm UTC
Jan 29, 2012 at 9:17pm UTC
Remove the semicolen after at the end of the if statement.
Jan 29, 2012 at 9:17pm UTC
if statements shouldn't have a semi-colon after them (after the parentheses), neither should else .
Wazzak
Last edited on Jan 29, 2012 at 9:17pm UTC
Jan 29, 2012 at 9:18pm UTC
Remove the semicolon after if (name == "mark" )
and else
.
Jan 29, 2012 at 9:22pm UTC
Thaks alot you guys on this site are great
Jan 29, 2012 at 9:24pm UTC
On another note, what happened to you yesterday, Framework?!
Jan 29, 2012 at 9:43pm UTC
There is no Framework, only Zuul.
Jan 29, 2012 at 10:46pm UTC
Lynx876 wrote:On another note, what happened to you yesterday, Framework?! (sic)
I didn't do anything, it was those damn
hackers . They hijacked my e-mail too, which I still have yet to retrieve. As Moschops said, there's no more Framework. If you ever get an e-mail from him/her/them, ignore it.
Wazzak
Last edited on Jan 29, 2012 at 10:46pm UTC