C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 02-06-2010, 03:30 AM   #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.
girishkaitholil is offline   Reply With Quote
Old 02-06-2010, 03:38 AM   #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 -
ForzaItalia2006 is offline   Reply With Quote
Old 02-06-2010, 03:52 AM   #3
Registered User
 
Join Date: Jan 2010
Posts: 54
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
artistunknown is offline   Reply With Quote
Old 02-06-2010, 03:53 AM   #4
Registered User
 
Join Date: Jan 2010
Posts: 54
sorry I didn't see what the other person wrote they're right read that faqs
artistunknown is offline   Reply With Quote
Old 02-06-2010, 06:40 AM   #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();

}
girishkaitholil is offline   Reply With Quote
Old 02-06-2010, 06:42 AM   #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..
girishkaitholil is offline   Reply With Quote
Reply

Tags
cmd gets killed

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C window code - How easy is it to intergrate cmd code spadez C Programming 23 04-20-2009 07:35 AM
OOP Question DB Access Wrapper Classes digioz C# Programming 2 09-07-2008 04:30 PM
Error running program in cmd - cygwin.dll missing - JFonseka C Programming 5 08-27-2007 12:12 PM
Converting cmd arg to int InstaDeath C++ Programming 5 03-17-2004 09:45 PM
Little help with CMD robid1 C Programming 2 02-23-2003 04:09 AM


All times are GMT -6. The time now is 12:06 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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