I keep getting "Windows is Searching for a Solution" message

This is a discussion on I keep getting "Windows is Searching for a Solution" message within the C Programming forums, part of the General Programming Boards category; I'm very new to this. I don't know much about computers at all. I'm only doing this stuff cuz it's ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    4

    I keep getting "Windows is Searching for a Solution" message

    I'm very new to this. I don't know much about computers at all. I'm only doing this stuff cuz it's one of my classes(although I find it very interesting).

    I'm using Code Blocks 10.05 (it's what they have at school) for Windows 7. My compiler is GNU GCC Compiler. Wasn't sure whether to post here or the Windows thread.

    Anyway, I keep getting a window popping up saying the program has stopped working and windows is searching for a solution. It happens when I ask the user to input a number.

    This is the start of my program and it gives me the error as soon as I enter the first number:

    Code:
    int main()
    {
        int it = 0;
        float temp, mean, max = -100000, min = 100000, sum;
    
        printf("Enter first temperature: ");
        scanf("%f", temp);
    
        while (1)
        {
            printf("Enter next temperature: ");
            scanf("%f", temp);
        }
    
        return 0;
    }

    It'll run programs that don't involve user inputs.

    I posted this problem at the Code Blocks forum and one guy told me to turn on Full COmpiler Logging and sent me a link to this site, the other guy had a hissy fit because my problem didn't meet his wonderous standards and locked my post so no one else could help or reply. i had some words for him...

    Any help will be much appreciated! Thanks

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    You forgot to add the ampersand into the scanf("%f", &temperature);

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    that's embarrassing. i always make stupid mistakes like that. i looked at that for a long time too.
    thanks

  4. #4
    Registered User
    Join Date
    Sep 2010
    Posts
    69
    Quote Originally Posted by Adak View Post
    You forgot to add the ampersand into the scanf("%f", &temperature);
    Correct.
    scanf needs the address-of "temp" not the value of "temp".
    Code:
        scanf("%f", &temp);
    Also;
    Code:
        while (1)
    ???
    How do you plan to exit this loop ?

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    i plan to exit with a break, its just not in there yet

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by blerg View Post
    i plan to exit with a break, its just not in there yet
    Or you could use a signal value...
    Code:
    while (temp > 0) ...
    Then enter -1 to exit.

  7. #7
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    i orginally had it set up like that but my teacher wanted an indefinite loop with a break in it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  2. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Visual C++ 2005 linking and file sizes
    By Rune Hunter in forum C++ Programming
    Replies: 2
    Last Post: 11-12-2005, 09:41 PM

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