No dev c ++ giving an error: id returned 1exit status

Asked

Viewed 51 times

0

#include <stdio.h>  //biblioteca => Standard I/O

void tela1(){
    printf("*** FACEAR - EXEMPLO *** \n\n"); // Impressão na tela 
}

void TelaAjuda(){
    printf("*** COMPILACAO E EXECUCAO     *** \n" );
}
main()
{
    systen("cls");
    //Comentários no código
    tela();
    telaAjuda();    


    // Criação de variaveis 
    int a;
    int b;
    int s;

    // Inicialização com Zero
    a = b = s = 0;

    // Atribuição de valores
    a = 2;
    b = 3;
    s = a + b;



    // Impressão na tela 
    printf("O valor da variavel a , b \n");
    printf("Soma de a e b %i \n", s);

    //Solicitar um valor
    printf("Digite um valor: ");    
    scanf("%i", a);

    printf("Digitado %i \n", a);

    return 0;
}

1 answer

0

According to this reply of the question: C Compile error: Id returned 1 Exit status, in English:

Translated, via google Translate:

I can only assume that the old instance of your program is still running. Windows does not allow changing the files currently "in use" and the linker cannot write the new . exe to the top of the running file. Try to stop / kill your program.

I believe this will solve the execution of your code.

1) however there are a number of minor errors in your code, see:

...
main()
{
    systen("cls");
    //Comentários no código
...

The correct way to write the function is system("cls"); and to use you must include the directive: #include <cstdlib>

2) Note this section of your code when calling the functions:

 ...
            tela();
            telaAjuda();  
        ...

In turn, observe the implementation of its functions:

...
void tela1(){
    printf("*** FACEAR - EXEMPLO *** \n\n"); // Impressão na tela 
}

void TelaAjuda(){
    printf("*** COMPILACAO E EXECUCAO     *** \n" );
}
...

Their names are different!

  1. tela is different of tela1;
  2. TelaAjuda is different of telaAjuda

Remember that C++ is Case-sensitive

3) The last mistake, you may notice the warning:

Warning: format ľ%i' expects argument of type ¡int*', but argument 2 has type ễint' [-Wformat=]

in this passage:

 //Solicitar um valor
    printf("Digite um valor: ");    
    scanf("%i", a);

The right thing would be:

scanf("%i", &a);

Because the scanf requires the address of the variable a.

For more questions about scanf read this reply: Why don’t you need the & in the scanf();?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.