Find the answer to your Linux question:
Results 1 to 2 of 2
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Sep 2012
    Posts
    148

    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:
    Code:
    #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:
    Code:
    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
    Location
    Either at home or at work or down the pub
    Posts
    3,284
    I think the line
    Code:
    return 0
    be
    Code:
    return 0;
    Oops didn't notice the thread was closed...
    What do we want?
    Time machines!

    When do we want 'em?
    Doesn't really matter does it!?


    Conkybots: Interactive plugins for your Conkys!

Posting Permissions

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