Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    C++ password program issue. Syntax i think?

    Hello peoples, I have made a program that is supposed to check a passcode and it the passcode is correct then it tells you so but if not it gives you another chance to try. It is very simple program because I am very new to C++. the code is below:
    #include <iostream>
    using namespace std;
    int main(void)
    	bool loop = false;
    	int password = 2554;
    	int guess;
    	while(loop == false){
    		cout << "Please enter your passcode: ";
    		cin >> guess;
    		if(guess == password){
    			cout << "your passcode was correct thank you";
    			loop = true;
    		if(guess != password){
    			cout << "you passcode is incorrect, please try again";
    	return 0
    This is the error message:
    password.cpp:24:1: error: expected ; before } token
    I have tried many ways but I think its a sneaky syntax somewhere.

  2. #2
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Either at home or at work or down the pub
    I think the line
    return 0
    return 0;
    Oops didn't notice the thread was closed...
    Should you be sitting wondering,
    Which Batman is the best,
    There's only one true answer my friend,
    It's Adam Bloody West!

    The Fifth Continent

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts