Bonjour
voila j'ai un problème :p
j'aime faire de petit programme pour m'entrainer et faire des challenges mais la je bloque
en gros j'aimerais faire comment dire ... une condition de type char.
voila se que j'ai fait pour le moment mais qui ne marche pas
se qui se passe c'est que si je rentre un nombre ou des caractères supérieure à 4 ça conte comme "bon"
normalement je doit aller sur "if" que si je tape "access" mais la si je tape (azerty) ou (12345) ça me dirige sur "if"
en revanche si je tape une petite chaine comme (aze) ou (123) cela va bien dans "else if"
Code C/C++ :
#include <stdio.h>
#include <stdlib.h>
#include <FMOD/fmod.h>
#include <time.h>
#include <windows.h>
#include <string.h>
void Color(int couleurDuTexte,int couleurDeFond);
int main(int argc, char *argv[])
{
FSOUND_Init(44100, 32, 0);
FSOUND_SAMPLE *registr = NULL;
FSOUND_SAMPLE *hahha = NULL;
registr = FSOUND_Sample_Load(FSOUND_FREE, "registrationcomplete.wav", 0, 0, 0);
hahha = FSOUND_Sample_Load(FSOUND_FREE, "hahha.wav", 0, 0, 0);
int compteur = 0;
Color(15,1);
printf("\nChargement du Challenge....\n");
sleep(5000);
system("cls");
char acc = "access";
printf("******************************************************\n");
printf("* *\n");
printf("* Systeme Administrator *\n");
printf("* *\n");
printf("******************************************************\n");
printf("\n\nWhat's the magic Word ??\n\n");
scanf("%c", &acc);
if (acc == "access")
{
system("CLS" );
printf ("ok\n");
FSOUND_PlaySound(FSOUND_FREE, registr);
printf("\nLoading...\n");
sleep(2000);
system("CLS");
printf("\npress ENTER\n");
getch();
}
else if (acc != "access")
{
system("CLS" );
while (compteur < 30)
{
printf("You didn't say the Magic word !!! HAHAHA !!!\n");
compteur++;
}
FSOUND_PlaySound(FSOUND_FREE, hahha);
getch();
return 0;
}
system("CLS");
/*
instructions
*/
getch();
FSOUND_Sample_Free(registr);
FSOUND_Sample_Free(hahha);
FSOUND_Close();
return 0;
}
void Color(int couleurDuTexte,int couleurDeFond) // fonction d'affichage de couleurs
{
HANDLE H=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(H,couleurDeFond*16+couleurDuTexte);
}
_______________________________________________________________________
j'ai 16 ans et j'aime l'informatique, surtout les programmes
