Sunday, October 24, 2021

[SOLVED] How to get the output "Process returned x (0x0) execution time : x.xxxx s" with gcc and Atom editor?

Issue

When compiling the following code on CodeBlocks it shows me "Hello, world", the returned value and the execution time, but when I compile it on Atom or on terminal with "gcc code.c" and running the executable, it only prints "Hello, world".

How can I get the returned value and the execution time?

#include <stdio.h>

int main() {

  printf("Hello, world");

  return 0;
}

I am getting this

I expect to get this instead (like I do with CodeBlocks)


Solution

The only output command in your code is:

printf("Hello, world");

There is no command (function call) to calculate or output the execution time. When you run your program from within the IDE / debugger, it's the IDE / debugger itself which give you that information. It is not part of the output of your program.

If you'd like to have that output, you would have to add code to measure and output the execution time yourself.



Answered By - Binarus