HelperZ

This is a discussion on HelperZ within the C++ Programming forums, part of the General Programming Boards category; I have been owrking on a login script using pointers to store the passwords in a single pointer to access ...

  1. #1
    Denethor2000
    Guest

    Question HelperZ

    I have been owrking on a login script using pointers to store the passwords in a single pointer to access later when you try to log in. Here is my script, I need to know what is wrong with this, it won't let me put these variables into the pointer, why? please tell me how.

    #include<iostream.h>

    void main()
    {
    float login, passwd;
    float *store;
    cout<<"Please enter your login name:";
    cin>>login;
    cout<<"\nPlease enter your password:";
    cin>>passwd;
    *store==passwd;
    *store==login;
    if(login, passwd != &store)
    {
    cout<<"\nWould you like to register? y/n";
    }
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    == is to test a value for equality
    = is to assign a value

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Denethor200
    Guest
    well then how do i set those 2 variables to thaty pointer? i want it to be stackable too, so when they register, they will be put on the list, and then when they log in it calls the pointer and lets them in

  4. #4
    31173 h4x0r gnu-ehacks's Avatar
    Join Date
    Nov 2001
    Posts
    556
    store = passwd

    I'm pretty sure, haven't worked with pointers in a while.
    What will people say if they hear that I'm a Jesus freak?
    What will people do if they find that it's true?
    I don't really care if they label me a Jesus freak, there is no disguising the truth!

    Jesus Freak, D.C. Talk

    -gnu-ehacks

  5. #5
    Denethor2000
    Guest
    It calls it an overloaded function as a left operand

  6. #6
    31173 h4x0r gnu-ehacks's Avatar
    Join Date
    Nov 2001
    Posts
    556
    Hmm....This would probably be a good time to look it up in your C++ manual...
    What will people say if they hear that I'm a Jesus freak?
    What will people do if they find that it's true?
    I don't really care if they label me a Jesus freak, there is no disguising the truth!

    Jesus Freak, D.C. Talk

    -gnu-ehacks

  7. #7
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    here's how you would point to them:

    Code:
    #include<iostream.h> 
    
    void main()
    {
       float login, passwd;
       float *lstore, *pstore;
    
       cout<<"Please enter your login name:";
       cin>>login;
       cout<<"\nPlease enter your password:";
       cin>>passwd;
    
       lstore = &login
       pstore = &passwd;
    }
    there's no point in doing this though, login and passwd will atually store the values, the pointer just points to them.. you still need a memory location to store the values in.. so in this case there's no point having a pointer

    When you do this:

    store = &something;

    you aren't "storing something in the pointer", you are actually "pointing the pointer at something"

    hope this helps.
    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  8. #8
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    you aren't "storing something in the pointer'', you are actually 'pointing the pointer at something''
    You actually pointing to the "address" in the memory of it, not the actual thing, hence the "&" operator.

    Denethor200, why are you using pointers in this? I see no logic to it unless you are planning to use several different functions in this program and you are trying to overcome the problem of limited scope. If you were trying to do this, you would save each of these variables to the heap rather than using pointers.

    Just my thoughts...

  9. #9
    Denethor2000
    Guest

    Unhappy

    Erm, how do I do that?

  10. #10
    Denethor2000
    Guest
    Okay here is my latest code on this project:
    #include<iostream.h>

    void main()
    {
    int login, passwd;
    int* log = new int;
    int* pass = new int;
    *log = login;
    *pass = passwd;

    char answer;
    cout<<"Please enter your login name:";
    cin>>login;
    cout<<"\nPlease enter your password:";
    cin>>passwd;
    if(login != log)
    {
    cout<<"\nWould you like to register? y/n";
    cin>>answer;
    }
    }




    now, i need to know why it tells me that log is an *int and login is an int. How do I fix this? I tried usiong &log but it old me it was a **int.

Popular pages Recent additions subscribe to a feed

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