Thread: C Console

  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    6

    C Console

    hi guys.
    I am a beginner c programmer and I like to learn some things is strange for me.
    this time I have a question :
    I want to make a change in console that i had seen this before in an IDE in ubuntu (code::blocks).how can I change console in C programming in a way that every time i write a code and run it at the end of console before exiting show me the execution time of that program.
    know I know i could write a code in my file.c that calculate the time of starting and ending the program and show the difference of them.but i don't want this. Is there any possible way to change console or any other option in a way that do this for me??

    I use windows 7 home premium 64 bit and Pelles C 7 64bit

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > how can I change console in C programming in a way that every time i write a code and run it at the end of console before exiting show me the execution time of that program.
    Unless you've messed something up, this is exactly what happens.

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        cout << "Hello world!" << endl;
        return 0;
    }
    This is the output
    Code:
    Hello world!
    
    Process returned 0 (0x0)   execution time : 0.002 s
    Press ENTER to continue.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    161
    Quote Originally Posted by Salem View Post
    > how can I change console in C programming in a way that every time i write a code and run it at the end of console before exiting show me the execution time of that program.
    Unless you've messed something up, this is exactly what happens.

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        cout << "Hello world!" << endl;
        return 0;
    }
    This is the output
    Code:
    Hello world!
    
    Process returned 0 (0x0)   execution time : 0.002 s
    Press ENTER to continue.
    That is not C, that is C++

  4. #4
    Registered User
    Join Date
    Jul 2013
    Posts
    6
    Thanks to Salem and FloridaJo But I don't get how it is work....
    again, I just to change my console output in a way that without embedding a code in my project to calculate the execution, it did it automatically.
    i had seen this feature in Code::Blocks(IDE) in my ubuntu 12.04 OS before.and I don't know how to do it in windows and my pelles C IDE.
    Does any one know how to to this.
    Please help me

  5. #5
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    Quote Originally Posted by FloridaJo View Post
    That is not C, that is C++
    So, whats your point? The end result is still the same with both languages.

  6. #6
    Registered User
    Join Date
    Jul 2013
    Posts
    6
    hi Syscal
    the code in the first answered post represented by Salem is not work in my IDE(=Pelles C or DEV C++) and it is because I do not know how to use it or the code is not my answer.
    it is what i do:
    i copy the text in first post and paste it in my IDE and i do not see the result I want...
    please help me.what should I do?

  7. #7
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    Here is a C equivalent that should compile

    Code:
    <stdio.h>
    
    int main(int argc, char ** argv){
    
      printf("Hello World\n");
    
      return 0;
    }
    Save the code in a file named "hello.c". Compile and it will give you the same result.
    Last edited by Syscal; 07-05-2013 at 07:09 PM.

  8. #8
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    @Syscal - You forgot the #include

    Code:
    #include <stdio.h>
     
    int main(int argc, char ** argv){
     
      printf("Hello World\n");
     
      return 0;
    }

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    It seemed to me that the programming language was irrelevant.

    Are you just trying to get a line like this
    Process returned 0 (0x0) execution time : 0.002 s
    out of the Pelles IDE?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  10. #10
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    You could just get Code::Blocks for Windows.

    The other option is to write a small wrapper program that does what the Code::Blocks wrapper does (grab return code and execution time and write them to the console, then wait for a keypress), and modify your project so that it starts this helper instead of your program.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  11. #11
    Registered User
    Join Date
    Jul 2013
    Posts
    6
    Quote Originally Posted by Salem View Post
    It seemed to me that the programming language was irrelevant.

    Are you just trying to get a line like this
    Process returned 0 (0x0) execution time : 0.002 s
    out of the Pelles IDE?
    hello salem
    at first I am so sorry for this too much wait for my reply
    and yes, i am looking for this...this is what i mean....again i am sorry.
    now, do u know how can i do this?

  12. #12
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    You could try the Pelles C forums.

  13. #13
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    CIPHER_CS,
    This should do the job.

    Code:
    #include <stdio.h>
     
    int main (int argc, char** argv)
    {
        printf("Hello World\n");
        printf("\n");
        printf("Process returned 0 (0x0) execution time : 0.002 s\n");
        printf("Press ENTER to continue.\n");
        return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Console C++
    By Dakshin in forum C++ Programming
    Replies: 5
    Last Post: 05-23-2013, 01:35 PM
  2. In a console is there..
    By Raigne in forum Windows Programming
    Replies: 17
    Last Post: 06-24-2006, 05:02 PM
  3. Can someone help me with this console app please?
    By Marcos in forum C++ Programming
    Replies: 4
    Last Post: 07-26-2003, 07:04 PM
  4. Win32 Console App... multiple console buffers
    By Trauts in forum Windows Programming
    Replies: 2
    Last Post: 04-28-2003, 11:26 AM
  5. No more console, please...
    By Morph in forum Windows Programming
    Replies: 5
    Last Post: 02-19-2003, 09:03 AM