0

I am trying to make a game where you need to find the secret number between 1 & 100 and if you don't find it, the program tells you if it's larger or smaller. Here's the code:

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

 int main ( int argc, char** argv )
{
    int nombreMystere = 0, nombreEntre = 0;
    const int MAX = 100, MIN = 1;

    srand(time(NULL));
    nombreMystere = (rand() % (MAX - MIN + 1)) + MIN;

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

        // On compare le nombre entré avec le nombre mystère

        if (nombreMystere > nombreEntre)
            printf("C'est plus !\n\n");
        else if (nombreMystere < nombreEntre)
            printf("C'est moins !\n\n");
        else
            printf ("Bravo, vous avez trouve le nombre mystere !!!\n\n");
    } while (nombreEntre != nombreMystere);

    return 0;
}

Sorry, It's in French. So the error is:

Id returned 1 exit status.

alk
  • 69,737
  • 10
  • 105
  • 255
  • 7
    This error does not relate to your code, it's a linker error that means you are compiling the program erroneously. Can you post the way you compile the program? – Iharob Al Asimi Jun 04 '16 at 19:52
  • I use an ide to compile my program (codeblocks) so i'm not sure how to give you the way it compile the program – LE GRAND MASMAS Jun 04 '16 at 20:13
  • Check your global compiler settings as explained [here](http://stackoverflow.com/a/7992012/2873538). – Ajeet Shah Jun 04 '16 at 20:39
  • Your code successfully compiles & links on Linux Ubuntu 16.04 without error (e.g.: cc stuff.c -o stuff). It appears to work correctly too.... – TonyB Jun 04 '16 at 20:46
  • 1
    @TonyB For code that you don't know, or you haven't compiled yet use `cc -Wall -Werror stuff.c -o stuff`, instead, that would avoid many silly mistakes and typos. – Iharob Al Asimi Jun 04 '16 at 21:19
  • Is this windows? If it is, did codeblocks install *gcc*? And what is the name of your source file? – Iharob Al Asimi Jun 04 '16 at 21:26
  • 1
    @iharob actually the command I used was "make stuff" and let Make's default config compile and link stuff.c ... but your suggestion of adding "-Wall" and "-Werror" is great for a beginner. – TonyB Jun 04 '16 at 21:33
  • @TonyB Anyone who is careful should use them. If you want to do something that would throw a warning you can always skip specific types of warnings with `-Wno-`. – Iharob Al Asimi Jun 04 '16 at 21:35
  • That's not the error; that's just the summary at the end, telling you that linking failed. The actual error is before that. – melpomene Jun 05 '16 at 14:08

0 Answers0