Thread: Is my code causing my system to crash?

  1. #1
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693

    Is my code causing my system to crash?

    Code:
    #include <iostream>
    #include <stdio.h>
    
    
    
    int main()
    {
    double studentscores[100];
    int numA=0, numB=0, numC=0, numD=0, numF=0,i=0, score=0;
    double high=0, low=0,average, gpa=0;
    
    printf("test\n");
    
    
                    while(i<100)
                     {                         
                     studentscores[i]=0; 
                     i++;
                     }
    i=0;
    printf("please enter score here--\n");
    scanf("%d",score);
    printf("score= %d\n", score);
    
    
                         
        
        system("pause");
      return 0;  
    }


    im just using DEV-C++ to run my C programs because jgrasp is not working on my computer but everytime i compile and run this little snippet of code it just sends me a error report, does anyone know why? the Error says "exe file has encountered a problem, we are sorry for the inconvenience would you like to send an error report?"

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Probably. You need to read up on scanf. It needs a pointer to where it's storing the data. Put an ampersand in front of score:
    Code:
    scanf("%d", &score);
    EDIT: Oh, and iostream is C++. Pick a language, and post in the appropriate forum next time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fscanf causing a crash
    By dougwilliams in forum C Programming
    Replies: 6
    Last Post: 11-18-2007, 04:52 PM
  2. What does system crash mean?
    By alyeska in forum C++ Programming
    Replies: 4
    Last Post: 10-06-2007, 03:53 AM
  3. Epic System crash (quite funny)
    By projektaquarius in forum C++ Programming
    Replies: 3
    Last Post: 11-16-2006, 03:32 AM
  4. what is causing this seemingly simple app to crash?
    By Shadow12345 in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2002, 08:36 PM
  5. allegro causing a crash
    By kooma in forum Game Programming
    Replies: 5
    Last Post: 04-06-2002, 02:01 PM