Dumb Question

This is a discussion on Dumb Question within the C++ Programming forums, part of the General Programming Boards category; I feel really stupid asking this, but I'm not sure what i'm missing: (i'm using BCB6) Code: //--------------------------------------------------------------------- #include <vcl.h> ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    180

    Dumb Question

    I feel really stupid asking this, but I'm not sure what i'm missing:
    (i'm using BCB6)

    Code:
    //---------------------------------------------------------------------
    #include <vcl.h>
    #pragma hdrstop
    
    #include "Unit1.h"
    #include "Unit2.h"
    #include <string>
    //---------------------------------------------------------------------
    #pragma resource "*.dfm"
    TPasswrd *Passwrd;
    
    
    
    void __fastcall TPasswrd::OKBtnClick(TObject *Sender)
    {
    char user, pass;
    user = User1->Text;
    pass = Pass1->Text;
    
    if (user != "Chris" && pass != "chris1")
    {
           Application->MessageBoxA("Wrong password or username","ERROR",MB_OK);
           User1->Clear();
           Pass1->Clear();
    }
    else
    {
           Form1->File1->Enabled = true;
           Form1->Encryption1->Enabled = true;
           Form1->Tools1->Enabled = true;
           this->Close();
    }
    
    }
    it says : [C++ Error] Unit2.cpp(27): E2451 Undefined symbol 'string'

    what did I miss!

    thx,

    DW

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    You need to use either std::string, or put 'using namespace std;' after your includes.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    damn that was fast! thx

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    Is this a typo?
    Code:
    char user, pass;
    user = User1->Text;
    pass = Pass1->Text;
    
    if (user != "Chris" && pass != "chris1")
    You can't do this with char variables.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    Opps! Yup.

    Code:
    string  pass,user;

  6. #6
    Registered User
    Join Date
    Feb 2004
    Posts
    35
    And since that message is "Wrong password or username", you might want to use || instead of &&

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dumb question
    By travis999 in forum C Programming
    Replies: 3
    Last Post: 10-26-2007, 12:57 AM
  2. very dumb question.
    By Blips in forum C++ Programming
    Replies: 14
    Last Post: 11-08-2005, 08:37 AM
  3. Dumb question
    By dragon2309 in forum C Programming
    Replies: 18
    Last Post: 10-29-2005, 03:27 PM
  4. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  5. another dumb question - loop not working?
    By Captain Penguin in forum C++ Programming
    Replies: 8
    Last Post: 10-06-2002, 10:15 PM

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