000
16.06.2005, 17:35 Uhr
dreamweaver
|
Hallo,
ich muss ein Log in Programm in C programmieren. Es hat leider einen Fehler.
Hier erstmal der Code:
C++: |
#include <stdio.h> int checkPassword (char acEnteredPassword[], char acRealPassword[], int iLengthPassword); int checkName (char acEnteredName[], char acRealName[], int iLengthName); int main() { char acEnteredPassword[1000]; char acRealPassword[] = {'1','2','3','\0'}; char acEnteredName[1000]; char acRealName[] = {'U','s','e','r','\0'}; int iLengthName = sizeof (acRealName); int iLengthPassword = sizeof (acRealPassword); int iNameRight; int iPasswordRight; printf ("Please etner your log in name: "); gets (acEnteredName); printf ("\nPlease enter the Password: "); gets (acEnteredPassword); checkName (acEnteredName, acRealName, iLengthName); if (iNameRight) { printf ("\nThe log in name is right!"); } else { printf ("\nThis is the wrong log in name!"); } checkPassword (acEnteredPassword, acRealPassword, iLengthPassword); if (iPasswordRight) { printf ("\nThe password is right!"); } else { printf ("\nThis is the wrong password!"); } printf ("\n\n\n\n"); system ("pause"); return 0; }
int checkName (char acEnteredName[], char acRealName[], int iLengthName) { int iCount; int iNameRight = 1; for (iCount = 0; iCount < iLengthName; iCount = iCount + 1) { if (acEnteredName != acRealName) { return 0; } } return iNameRight; }
int checkPassword (char acEnteredPassword[], char acRealPassword[], int iLengthPassword) { int iCount; int iPasswordRight = 1; for (iCount = 0; iCount < iLengthPassword; iCount = iCount + 1) { if (acEnteredPassword != acRealPassword) { return 0; } } return iPasswordRight; }
|
Warum ist die Ausgabe immer right? Bitte helft mir. Es ist sehr dringend! |