Thread: scanf crashes graphics program

  1. #1
    Registered User mr_raging_money's Avatar
    Join Date
    Mar 2012
    Posts
    18

    Exclamation scanf crashes graphics program

    I have been working with simple graphics programs using graphics.h, and I noticed a problem while using it. When I run the program, it opens the graphics window and the text input and output window. I tried to make a simple menu system in the text window, and I would use scanf to determine if the graphics window started, or Instructions opened in the text window. I ran the program and it crashed almost immediately. I determined that scanf was causing it to crash by eliminating other things from my program.

    After this I tried putting the if statement that used the variable I used in the scanf statement for the menu in different parts of the program, trying to make it not crash. Nothing worked, so it seems to be scanf crashing it. Does anybody have a solution to not make the program crash/alternative menu options?

  2. #2
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    dont forget the '&' before the variable in scanf

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    You could always post your code, and describe specifically how it's "crashing". Use a debugger or write a signal handler to find out how your program is terminating.

    Also, graphics.h is terribly outdated and non-portable, so finding support (here) will be difficult.

  4. #4
    Registered User mr_raging_money's Avatar
    Join Date
    Mar 2012
    Posts
    18
    *throws arms up*
    thanks, rookie mistake

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My program crashes :|
    By Testify in forum C++ Programming
    Replies: 12
    Last Post: 06-27-2007, 11:48 AM
  2. My I/O Program crashes, I need some help
    By Guti14 in forum C Programming
    Replies: 4
    Last Post: 09-24-2004, 01:16 AM
  3. Odd program crashes
    By Mithoric in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2004, 11:37 PM
  4. Program crashes
    By fkheng in forum C Programming
    Replies: 12
    Last Post: 06-24-2003, 04:59 AM
  5. program crashes
    By Strut in forum Linux Programming
    Replies: 3
    Last Post: 02-10-2002, 10:49 AM

Tags for this Thread