[Help]Error

Posts 1–4 of 4 · Page 1 of 1
[Help]Error
Hello, i'm new in coding. I'm coding a small game (I know its not complciated) but still its my first program. I always get an error. Can someone say me why i get it?


Visual Basic\MinetMaxJeu\main.c||In function 'main':|
Visual Basic\MinetMaxJeu\main.c|60|error: 'end' undeclared (first use in this function)|
Visual Basic\MinetMaxJeu\main.c|60|error: (Each undeclared identifier is reported only once|
Visual Basic\MinetMaxJeu\main.c|60|error: for each function it appears in.)|
||=== Build finished: 3 errors, 0 warnings ==


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
do
{
int nombreMystere = 0;
int nombreScan = 0;
const int MAX = 100, MIN = 1;
srand(time(NULL));
nombreMystere = (rand() % (MAX - MIN + 1)) + MIN;
int nombre = 0;

do
{
printf("Quel est le chiffre ? ");
scanf("%d", &nombreScan);

if (nombreScan < nombreMystere)
{
printf("\nC'est plus !\n\n");
nombre++;
}
else if (nombreScan > nombreMystere)
{
printf("\nC'est moins !\n\n");
nombre++;
}
else
{
printf("\nBravo, vous avez trouve le nombre mystere !!!\n\n");
nombre++;
printf("Ca vous a pris %d coups pour reussir!", nombre);
}



}while (nombreMystere != nombreScan);

printf("Voulez-vous recommencer?");
printf("\n\n1. Recommencer");
printf("2. Quitter");

int end = 0;

scanf("%d", &end);

if (end = 1)
{
printf("\n\n");
}
else
{
printf("\n\n");
}


}while (end != 0);





return 0;
}
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
	int end = 0;

	do
	{
		int nombreMystere = 0;
		int nombreScan = 0;
		const int MAX = 100, MIN = 1;
		srand(time(NULL));
		nombreMystere = (rand() % (MAX - MIN + 1)) + MIN;
		int nombre = 0;

		do
		{
			printf("Quel est le chiffre ? ");
			scanf("%d", &nombreScan);

			if (nombreScan < nombreMystere)
			{
				printf("\nC'est plus !\n\n");
				nombre++;
			}
			else if (nombreScan > nombreMystere)
			{
				printf("\nC'est moins !\n\n");
				nombre++;
			}
			else
			{
				printf("\nBravo, vous avez trouve le nombre mystere !!!\n\n");
				nombre++;
				printf("Ca vous a pris %d coups pour reussir!", nombre);
			}
		}
		while (nombreMystere != nombreScan);

		printf("Voulez-vous recommencer?");
		printf("\n\n1. Recommencer");
		printf("2. Quitter");

		scanf("%d", &end);

		if (end = 1)
		{
			printf("\n\n");
		}
		else
		{
			printf("\n\n");
		}


	}
	while (end != 0);

return 0;
}
Fixed, you declared your end var inside the do-while loop, and obviously that while(xxx) isn't inside it, so you need to declare it outside of the loop.

And learn how to indent your code...
am I the only one who noticed this?
"Visual Basic\"

Daum... This ain't visual basic...
Its because the folder of the file is named C/C++/Visual Basic
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?