Thread: Help, my program wont run!

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    Exclamation Help, my program wont run!

    I made a very simple text program today, reading from a book and it told me to create it. I compiled the script and it was all good but when I went to run it it just flashed command prompt on my screen and went away.

    #include <stdio.h>
    main()
    {
    printf("My name is Sean Katzenstein\n");
    }

    This is my script, please help and thank you.

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    36
    What compiler are you using there may be an easier solution.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    What IDE are you using there may be an easier solution.

  5. #5
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    At the top of your code, add a #include <conio.h>. And at the end of the main function, add a system("pause");. This will ask you to "Press any key to continue. . ." when the program's done. This only works on Windows, though.

  6. #6
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by Babkockdood View Post
    At the top of your code, add a #include <conio.h>. And at the end of the main function, add a system("pause");. This will ask you to "Press any key to continue. . ." when the program's done. This only works on Windows, though.
    Actually, conio.h is specific to Turbo C, and is not required for the system("pause") call. system() is a function from stdlib.h.

  7. #7
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Quote Originally Posted by anduril462 View Post
    Actually, conio.h is specific to Turbo C, and is not required for the system("pause") call. system() is a function from stdlib.h.
    Oh, you're right, I was thinking of getch. conio.h is included with most compilers for Windows, actually.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Run program on webserver
    By Yarin in forum Tech Board
    Replies: 14
    Last Post: 08-28-2009, 11:30 AM
  2. Re-doing a C program to run in Win2000 or XP
    By fifi in forum C Programming
    Replies: 5
    Last Post: 08-17-2007, 05:32 PM
  3. Replies: 3
    Last Post: 07-11-2005, 03:07 AM
  4. plz help me run this program!!!
    By galmca in forum C Programming
    Replies: 8
    Last Post: 02-01-2005, 01:00 PM
  5. Cannot run program in background?
    By registering in forum Linux Programming
    Replies: 3
    Last Post: 06-16-2003, 05:47 AM