Jump to content

Recommended Posts

Posted (edited)

Pessoal, estou a desenvolver um projeto em C e estou a perder tempo com erros basicos. Nesta parte é um simples sistema de login com if e else mas que nao quer entrar seja com senha correta ou errada.. Que se passa?

#include <stdio.h>
#include <stdlib.h>
#include "conio.c"
#include "conio.h"
#include "windows.h"
#include <curses.h>
#include <math.h>
#include "unistd.h"
#define ENTER 10
#define ESCAPE 27
int main()
{
//vars
char loginID[50],loginPW[50];
char adminID[50]="admin";
char adminPW[50]="abc";
//vars
loginAdmin:
            system("cls");
            clrscr();
            system("color b5");
            gotoxy(20,14);
            printf("Login:");
            gotoxy(20,16);
            gets(loginID);
            setbuf(stdin,NULL);
            gotoxy(20,19);
            printf("Senha:");
            gotoxy(20,21);
            gets(loginPW);
            setbuf(stdin,NULL);
            system("cls");
            setbuf(stdin,NULL);
            if(adminID != loginID || adminPW != loginPW){
                textcolor(LIGHTRED);
                printf("Senha ou Login incorretos! Aguarde enquanto volta a tentar...\n\n");
                _sleep(1000);
                system("cls");
            clrscr();
            system("color b5");
            goto loginAdmin;
            }
            else if(adminID == loginID && adminPW == loginPW){
                printf("Sucesso!");
            }
return 0;
}

ajudem-me!

Edited by pmg
GeSHi
Posted

C nao suporta comparar string(array de caracteres) com o operador ==, tens que usar o strcmp

  • Vote 1

Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender.

A beleza de um código está em decompor problemas complexos em pequenos blocos simples.

"learn how to do it manually first, then use the wizzy tool to save time."

"Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.