Bug in a C code [duplicate]

-1

I know, this code is very simple and it's kind of ugly too, I'm a beginner and I'm trying to facilitate this function, can anyone tell me what the error is?

Image of the bug:

#include<stdio.h>#include<stdlib.h>#include<string.h>intmain(){chartempo[5],a[25];intop;printf("EAE MEN\n\n1.Apagar o bixin\n2.Desligar e ligar dnv\n3.Tirar uma sonequinha\n");
scanf("%d",&op);

switch(op){
case 1:
a=="shutdown -s -t ";
printf("Desliga em qts segundos msm?\n");
scanf(" %s",tempo);
strcat(a,tempo);
break;
case 2:
a=="shutdown -r -t ";
printf("Reinicia em qts segundos msm?\n");
scanf(" %s",tempo);
strcat(a,tempo);
break;
case 3:
a=="shutdown -h -t ";
printf("Sonequinha em qts segundos msm?\n");
scanf(" %s",tempo);
strcat(a,tempo);
break;
default:
printf("Numero Invalido, bro, sabe ler n eh?\n");
return 0;
}
system(a);

return 0;
system("pause");
}
    
asked by anonymous 16.04.2017 / 23:12

1 answer

0

You are using the relational operator == instead of the assignment operator = , in all statements where a , character string, is left operator.

The string a is an array of type char . In C, you can not make an assignment statement for this data type. You need to use the strcpy(arrayDeDestino, arrayFonte) function.

    
16.04.2017 / 23:21