help with C++
been here like a year now and decided i want to learn C++ so i can help out more.
ive been practicing a few things since some of it seems to be the same as PERL. i ran into an error tho... what i want this simple program to do is ask people to type in a username and then i want it to ask them for a password. people who put the wrong pass in get this message "Incorrect Pass. Good-Bye." and people who put the right one get this message "You have accessed my information. You are lame!" For some reason tho, every time you put in your username you get the message you would get for a correct password instead of the "Enter Password" prompt. heres is the code Code:
//basic pass also if anyone could respond with what exactly the beginning "int main()" function does would also be appreciated hehe...i have no clue what its for. i know it has something to do with declarations maybe? |
Weird, I spent like 20 miniutes and I still couldn't figure it out. Me and you are probally around the same c++ skill level :-(
|
Code:
#include <iostream.h> 1. Main problem you were seeing is because "name" was an integer and you were inserting text. So it immediately dropped to the if statements. 2. Changed "return;" to "return 0;" 3. Initialized "pass" to 0. :D *EDIT* Added a little spacing to the code. *EDIT* *EDIT* Made the second if statement an else if, not a big deal in this size program, but it's good habit to get in to. *EDIT* |
Might want to change pass to a char too ....
|
thanks for the help.
i dont understand tho what the [32] means after name.... thanks again |
Scorp: Yes, but he had everything setup for the password to == 5, so I just left that alone :D .
x-scythe: the [32] designates the size of "name". So in this case, "name" is 32 characters long. |
All times are GMT -4. The time now is 05:14 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.