Zelaron Gaming Forum  
Stats Arcade Portal Forum FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read
Go Back   Zelaron Gaming Forum > The Zelaron Nexus > Science and Art > Tech Help

 
 
Thread Tools Display Modes

 
Some Help!
Reply
Posted 2002-04-08, 05:55 PM
Ok im tryin to write a program, that is sort of like a password protection thingy, where it asks the password, and if u get it right it says, correct you may continue (after that would let u continue with program, in future program) and if u type it wrong It will, deny you and leave you with nothing.

Now, my problem is, declaring the variables..
this is wat I got so far
Code:
#include <iostream> 
#include <conio.h> 
using namespace std; 

int main() 
{ 
int shokka; //correct password 
int ??????; // wrong password
im stuk on the second variable... How can I declare it if it can be more than one thing???? like i dont understand.... how to declare a variable that will have different inputs....like it could be "defew" or "moomannHy89"

Thnx
Old
Profile PM WWW Search
spa is neither ape nor machine; has so far settled for the in-betweenspa is neither ape nor machine; has so far settled for the in-between
 
spa
 



 
Reply
Posted 2002-04-08, 08:35 PM in reply to spa's post "Some Help!"
You have to use strings instead of integers to store passwords.

Strings are just arrays of characters, and there are plenty of useful functions in stdlib.h for dealing with them.
I think I'm lost.
Old
Profile PM WWW Search
Badass Gandhi is neither ape nor machine; has so far settled for the in-betweenBadass Gandhi is neither ape nor machine; has so far settled for the in-between
 
Badass Gandhi
 



 
Reply
Posted 2002-04-09, 08:13 AM in reply to spa's post "Some Help!"
Code:
#include <stdio.h>
#include <string.h>
#include <conio.h>

const char sPwdCorrect[]="shokka";

int main(){
  char sPwdEntered[1024];
  printf("Enter Password:");
  gets(sPwdEntered);
  if(strcmp(sPwdEntered,sPwdCorrect)!=0){
    printf("Password Incorrect\n");
    return 1;
  }//endif(strcmp(sPwdEntered,sPwdCorrect)!=0)
  printf("Password Correct\n");
  //continue program here
  return 0;
}
Study it and learn. If you're a beginning programmer, I would suggest starting with BASIC instead of C
--WetWired
Old
Profile PM WWW Search
WetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusionWetWired read his obituary with confusion
 
 
WetWired
 
 

Bookmarks

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules [Forum Rules]
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 03:10 AM.
'Synthesis 2' vBulletin 3.x styles and 'x79' derivative
by WetWired the Unbound and Chruser
Copyright ©2002-2008 zelaron.com
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.