1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

May someone help me with my program????

Discussion in 'C' started by SamuelChow, Jan 16, 2007.

  1. SamuelChow

    SamuelChow New Member

    Joined:
    Jan 5, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Hong Kong
    May someone help me with my program???? :confused:
    It said the program have 2 error in line 12 & 51(as pointed)
    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<time.h>
    /********************Sudoku by Chow Samuel See Chai 5A*******************/
    int x,y;
    int matrix[9][9], box[9];
    char filename[30];
    FILE *fp;
    void welcome(void);
    void rules(void);
    void level(void);
    void board(char);<------------------error 1
    void enter(int);
    void check(int);
    main()
    {
          welcome();
          rules();
    }
    void welcome()
    {
         printf("Welcome to Sudoku Game Version 2.0\n\n");
         printf("Thanks for playing this game!\n\nHope you enjoy the game!\n");
    }
    void rules()
    {
         printf("\nRules to play:\n");
         printf("Enter a numerical digit from 1 through 9 starting with various digits given in some cells.\n");
         printf("Each row, column, and cell must contain only one instance of each numeral.\n");
         printf("Are you ready ? (1 - Yes, 0 - No)\n");
         scanf("%d", &x);
         if(x==1)
             level();
         else
             exit(1);
    }
    void level()
    {
     printf("Which level do you want to play? (1-easy, 2-normal, 3-hard)\n");
     scanf("%d", &y);
     switch(y)
     {
    
      default:
       printf("Error! Please enter again!\n");
       level();
        fclose(fp);
        }
    }
    void board(char filename[30])
    {   <-------------------------------------------error 2
     int i,j,z;
     fp=fopen(filename,"r");
        if(fp==NULL)
     {
        printf("Cannot open file!\n");
        level();
     }
        while((z=fgetc(fp))!=EOF){
                                                                
             printf("|-|-|-|-|-|-|-|-|-|\n");
             for(i=0;i<9;i++)
             {
                   for(j=0;j<=9;j++)
                   {
                       z = fgetc(fp);
             
              printf("|%c",z);
                       
                       matrix[i][j] = z;
                 
                   }                 
             }
        printf("\n");     
        printf("|-|-|-|-|-|-|-|-|-|\n");
        }    
    }
    void enter(int matrix[9][9])
    {
         int a,b,c;
         
         printf("Enter the position that you want to enter numbers: (eg. 1,1)\n");
         scanf("%d,%d", &a,&b);
         
         if(matrix[a][b]==0)
         {
                 printf("Wrong entering!\n");
                 printf("Please enter the position again!\n");
                 enter(matrix);
         }
         
         if(matrix[a][b]!=0)
         {
                 printf("Enter the number that you want to put at the position:\n");
                 scanf("%d", &c);
                 
                 matrix[a][b] = c;
                 
                 check();      
         }
    }
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    The function definition and the declaration does not match.
     
  3. SamuelChow

    SamuelChow New Member

    Joined:
    Jan 5, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Hong Kong
  4. SamuelChow

    SamuelChow New Member

    Joined:
    Jan 5, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Hong Kong
    How can I insert a puzzle in the program?
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    Which puzzle you are trying to include.
     
  6. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    Please consider that you are sitting in your chair listening to your brain hum. We are not. If you'd like to insert a crossword puzzle, consider scanning the NY Times and placing an image.
     
  7. SamuelChow

    SamuelChow New Member

    Joined:
    Jan 5, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Hong Kong
    sorry, I want to insert a Sudoku puzzle
     
  8. SamuelChow

    SamuelChow New Member

    Joined:
    Jan 5, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Hong Kong
    I mean to insert a Sudoku puzzle file
     
  9. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    Just Insert it the way you have inserted the first file.
     
  10. SamuelChow

    SamuelChow New Member

    Joined:
    Jan 5, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Hong Kong
    Thx~ ;)
     
  11. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    My pleasure.
     

Share This Page