Code::Blocks does not print the output of a basic code

Asked

Viewed 25 times

1

  1. Hey, guys, what’s up? I am starting to learn C language and installed it manually in my Ubuntu 20.04 OS gcc 9.3.0. I installed codeblocks 20.3:

Starting Code::Blocks Release 20.03 rev 11997 2020-04-18, 19:47:24 - wx3.0.4 - gcc 9.3.0 (Linux, Unicode) - 64 bit Ending application because Another instance has been Detected!

I made the settings in the codeblocks application, such as: the terminal, the instances and also when starting I created a project. However, when executing this code:

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

void main() {

//Permite usar acentos
setlocale(LC_ALL, "");
printf("Olá");

float b = 50.6;
printf("O valor de b é %f\n," b);
printf("f%", &b);

int a = 60;
printf("%d", a + b);
printf("o valor de a é = %d\n", a );
scanf("%d", &a);

char letra = "t";
printf("O valor de c é = %c \n", letra);
fflush(stdin);
scanf("%c", &letra);
printf("O valor de c mudou para %c", letra);

}

the codeblocks returns in the terminal:

Process returned 0 (0x0)   execution time : 0.001 s
Press ENTER to continue.

In logs & others in codeblocks:

||=== Build file: "no target" in "no project" (compiler: unknown) ===|
||=== Build finished: 0 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Does anyone know how to solve this problem?

Thanks in advance to those who are willing to understand the problem, Thank you.

  • Here: printf("O valor de b é %f\n," b); to , must precede b and not being inside the format string. This: printf("f%", &b); has no sense, the format is syntactically wrong. This: char letra = "t"; is wrong, the correct is: char letra = 't';, quotes apply to strings and not to a variable declared as a single character.

  • Hello. I made the minor modifications to the syntax you specified, but not yet compiled. Thank you very much for entering the errors.

  • I hope you know how to interpret the message "Ending application because Another instance has been Detected!". With the appropriate changes here ran as expected. The command fflush(stdin); has undefined behavior for incoming streams (maybe works on some S.O.).

No answers

Browser other questions tagged

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