Thread: System Pause Error please help

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

    System Pause Error please help

    Code:
    [QUOTE]#include<stdio.h>
    
    int main () {
    int i,j,max_c, max_j;
    int num_shows;
    
        
        FILE * fin;
        fin = fopen("ucfidol.txt","r");
        
        
        fscanf(fin,"%d", &num_shows);
        printf("%d\n",num_shows);
        fscanf(fin,"%d",&max_c);
        printf("Number of contestants = %d\n", max_c);
        fscanf(fin,"%d",&max_j);
        printf("Number of judges = %d\n", max_j);
        
        
    
    //int scores[max_c][max_j];
        //for(i=1;i<=max_c;i++)
            //fscanf(fin,"%d",&max_c);
        //for(j=1;j<=max_j,j++)
            //fscanf(fin,"%d",&max_j);
        
        
        
        
        fclose(fin);
    
    system("PAUSE");
    I am trying to write a code but I keep getting an error with the system pause. I cant seem to figure it out. Even for other codes I have been trying to write.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    24
    For my class our teacher told us to. This is the only way we learned how to keep the output window open

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by dubbin240 View Post
    I am trying to write a code but I keep getting an error with the system pause.
    What error?
    Quote Originally Posted by dubbin240 View Post
    I cant seem to figure it out.
    I can't either, because you didn't tell me what error you got.
    Code:
    #include<stdilb.h>
    #include<stdio.h>
    int main( void )
    {
        system( "pause" );
        printf( "error?\n" );
        return 0;
    }
    If you don't get an error there, then system isn't your problem. So, what error are you getting?


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    24
    I attached a snip of the error


    Attachment 10430

    Code:
    //int scores[max_c][max_j];
        //for(i=1;i<=max_c;i++)
            //fscanf(fin,"%d",&max_c);
        //for(j=1;j<=max_j,j++)
            //fscanf(fin,"%d",&max_j);
    Also Im not too good with arrays. If I want to read in from a file and store the numbers as an array would this be close?

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    See the top two lines of my example? Those are #include directives. They basically say "use the following file". stdlib.h is required for the use of the system function.

    Anytime you see 'X is undeclared', it means you are either trying to call a function or variable that it knows nothing about. It doesn't know anything about it, because it only knows about what is above it in the file. If you haven't included the appropriate headers at that point, it knows nothing of what the hold.

    edit - for your array edit question

    Arrays are basically like drawers in a cabinet. Each drawer holds whatever type the array is. The drawers of an array of integers each store one integer:
    Code:
    int array[ 5 ];
    This would have five drawers, each one holding one int. To put something in one directly:
    Code:
    array[ 2 ] = 12345;
    To put something in with say, scanf, we can do:
    Code:
    scanf( "%d", & array[ 2 ] );
    To put something in each drawer in a loop:
    Code:
    int x = 0;
    for( x = 0; x < 5; x++ )
        scanf( "%d%*c", & array[ x ] );
    Or something to that effect.


    Quzah.
    Last edited by quzah; 03-18-2011 at 05:32 PM.
    Hope is the first step on the road to disappointment.

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by dubbin240 View Post
    I attached a snip of the error


    Attachment 10430
    #include stdlib.h

  8. #8
    Registered User
    Join Date
    Mar 2011
    Posts
    24
    ok thanks that helped...its weird I have never used the standard library but I have always used system pasue

  9. #9
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by dubbin240 View Post
    ok thanks that helped...its weird I have never used the standard library but I have always used system pasue
    Well, for future... everything that's not a C keyword is either part of the standard library or something you wrote...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. system calls with cygwin
    By moorecj in forum C++ Programming
    Replies: 3
    Last Post: 07-28-2010, 10:26 PM
  2. beginner help!!!
    By robski in forum C++ Programming
    Replies: 4
    Last Post: 03-23-2010, 01:26 PM
  3. How to model a system?
    By ovid in forum C++ Programming
    Replies: 1
    Last Post: 03-05-2010, 09:18 AM
  4. Press a key
    By siavoshkc in forum C++ Programming
    Replies: 30
    Last Post: 01-21-2006, 10:15 AM
  5. New system build wont boot
    By lightatdawn in forum Tech Board
    Replies: 7
    Last Post: 12-02-2005, 06:58 AM