Is my code causing my system to crash?

This is a discussion on Is my code causing my system to crash? within the C Programming forums, part of the General Programming Boards category; 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, ...

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

    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,498
    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, 03: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, 02: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, 07:36 PM
  5. allegro causing a crash
    By kooma in forum Game Programming
    Replies: 5
    Last Post: 04-06-2002, 01:01 PM

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