problem with text input from user

Talk about making games.

problem with text input from user

Postby cyber ruler » Wed Jun 11, 2008 12:09 am

so, i have a textbox the user types into (it's for passwords), and it's not working the way it should, i think.
I have it so when the user presses enter, it runs this:
Code: Select all
if (passinput.text == "password")
{
    ...
}

I thought this would work, but it didn't.
I also tried this, which is how you do it in most programming languages:
Code: Select all
if (passinput$ == "password")
{
    ...
}

so... anyone know how to do this *cough* *sgtsparky* *cough* *makslane* *cough*
All of my friends tell me programming is my thing. I go to tech school and I'm in I.T., yep, programming all day. My friends ask for help all of the time. But, they tell me my graphics suck... and I have to agree. O, well :/
cyber ruler
 
Posts: 52
Joined: Sat Apr 28, 2007 7:59 pm
Location: Je ne parle englais : /
Score: 0 Give a positive score

Re: problem with text input from user

Postby pyrometal » Wed Jun 11, 2008 2:55 am

You have to use strcmp() to compare strings. It returns 0 when the strings are equal, therefore, use the "!" in front of it to get a "true"(aka: 1) value for your if statement to proceed.

Code: Select all
if( !strcmp(passinput.text, "password"))
{
    ...
}
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest