Learning the basics

This is a discussion on Learning the basics within the C++ Programming forums, part of the General Programming Boards category; Okay im a noob and need help im trying to make a super basic password system using 10 as the ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    10

    Learning the basics

    Okay im a noob and need help im trying to make a super basic password system using 10 as the password. It works along with every other number i type in. here is the snippet:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        int a, b;
        a = 10;
        cin>> b;
    
        if (b = a)
        cout<<"good job";
        
        else
        cout<<"fail!";
    }
    ps im not using this as a password system i just want to get a feel for variables
    can someone help me find the problem

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Code:
    if (a == b)
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,623
    b=a is assignment

    b==a compares them and returns true if they're equal
    Devoted my life to programming...

  4. #4
    Registered User
    Join Date
    Apr 2010
    Posts
    10
    thank you so much i didn't really understand the == until now and i didnt realize thats what i needed thanks again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Machine Learning with Lego Mindstorms
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 01-30-2009, 01:34 PM
  2. Best Approach for Learning
    By UCnLA in forum C Programming
    Replies: 5
    Last Post: 03-21-2008, 02:35 AM
  3. Need Help On a Simple Bank Program
    By oobootsy1 in forum C# Programming
    Replies: 9
    Last Post: 08-08-2005, 10:51 AM
  4. Fun Learning a New Language
    By UnregdRegd in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-30-2003, 10:03 PM
  5. Learning Rate Of C++
    By Krak in forum C++ Programming
    Replies: 27
    Last Post: 01-29-2003, 12:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21