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,651
    I think the line
    Code:
    return 0
    be
    Code:
    return 0;
    Oops didn't notice the thread was closed...
    "I used to be with it, then they changed what it was.
    Now what was it isn't it, and what is it is weird and scary to me.
    It'll happen to you too."

    Grandpa Simpson



    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
  •