cmd gets killed.

This is a discussion on cmd gets killed. within the C Programming forums, part of the General Programming Boards category; Hey, I am new to programming. I am trying to learn programming myself. I just set up everything using the ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Location
    Thodupuzha, Kerala, India
    Posts
    3

    Talking cmd gets killed.

    Hey,

    I am new to programming. I am trying to learn programming myself. I just set up everything using the c for dummies book and created the first goodbye program as described it it. It compiled well without any problems. DONE was the result. Now when i run the program the cmd gets killed. It doesnt even take one second on screen to get killed. I know my program is running well but cmd gets killed or just flashes out. Please advice.

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    18
    Hey,

    I assume you're working on a Windows box?

    Please read this FAQ entry: Cprogramming.com FAQ > Stop my Windows Console from disappearing everytime I run my program?

    - Andi -

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    150
    I'm new to programming to but I think your writing a console app and the reason the program just flashes is because you have to put something in the code to keep the window open like scanf() function unless I'm totally wrong

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    150
    sorry I didn't see what the other person wrote they're right read that faqs

  5. #5
    Registered User
    Join Date
    Feb 2010
    Location
    Thodupuzha, Kerala, India
    Posts
    3
    Hey, Thank you very much.. It helped me a lot. and i have edited the c program found there to my convenience.. This is my first day of programming. And I am successful. I made it like after executing the program just a enter stroke is required to kill the cmd. I am so fascinated, Hooray, I am coding well. am I right... ! he he..


    Thank you once again and the code edited by me goes like this..

    insert
    Code:
    #include <stdio.h>
    
    void myflush ( FILE *in )
    {
      int ch;
    
      do
        ch = fgetc ( in ); 
      while ( ch != EOF && ch != '\n' ); 
    
      clearerr ( in );
    }
    
    void mypause ( void ) 
    { 
      printf ( "Press [Enter] to continue . . ." );
      fflush ( stdout );
      getchar();
    } 
    
    int main ( void )
    {
      int number;
    
      // Test with an empty stream
      printf ( "Hello, world!\n" );
      mypause();
    
    }

  6. #6
    Registered User
    Join Date
    Feb 2010
    Location
    Thodupuzha, Kerala, India
    Posts
    3
    I really dont know what the above code is.. but some part, my intuition told me "edit." i edited. it worked for me. Thank you Andy..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 23
    Last Post: 04-20-2009, 07:35 AM
  2. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  3. Error running program in cmd - cygwin.dll missing -
    By JFonseka in forum C Programming
    Replies: 5
    Last Post: 08-27-2007, 12:12 PM
  4. Converting cmd arg to int
    By InstaDeath in forum C++ Programming
    Replies: 5
    Last Post: 03-17-2004, 08:45 PM
  5. Little help with CMD
    By robid1 in forum C Programming
    Replies: 2
    Last Post: 02-23-2003, 03:09 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21