Problem with output

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
Remove the semicolen after at the end of the if statement.
if statements shouldn't have a semi-colon after them (after the parentheses), neither should else.

Wazzak
Last edited on
Remove the semicolon after if (name == "mark") and else.
Thaks alot you guys on this site are great
On another note, what happened to you yesterday, Framework?!
There is no Framework, only Zuul.
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
Topic archived. No new replies allowed.