Thread: Simple problem with a function call towards a pre-existing function

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    5

    Simple problem with a function call towards a pre-existing function

    Were given the header file (which only contains the function prototype) and the object file with the defenition to a function that prompts the user to enter the filename (a file of only integer numbers), to which the function will then store the integers into an array.

    the header file also has 2 constants defined: ROWS = 9, COLS = 9.
    The function prototype is:

    void LoadPuzzle(int original[ROWS][COLS], int solution[ROWS][COLS], int rows, int cols);

    Code:
    #include <stdio.h>
    #include "loadPuzzle.h"
    
    int main()
    {
        int original[ROWS][COLS];
        int solution[ROWS][COLS];
        
        
        LoadPuzzle( original[ROWS][COLS], solution[ROWS][COLS], ROWS, COLS);
        
        printf("%d", original[1][5]);
        
        return 0;
        
    }
    with this I get the following warning: "warning: passing arg1 of 'LoadPuzzle' makes pointer from integer without a cast"

    messing around with the & and * I still didn't have any luck. The program/function will run but as soon as I enter in the filename with all the integers I get a segmentation error. I know it doesn't help not being able to see the definition for LoadPuzzle(), the header and object file for that function is given by the professor, others have made it work so I know 100% that the function is written correctly without any errors. Any help would be greatly appreciated! Thanks!

  2. #2
    The C eater *munch*
    Join Date
    Oct 2006
    Posts
    101
    maybe paste the content of loadPuzzle.h?

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    5
    Sure thing:

    * This file contains the function prototype of the function LoadPuzzle() *
    * defined in loadPuzzle.c and the #defines for ROWS and COLS which sets *
    * the size of the two-dimensional arrays used for the sudoku puzzle and *
    * its solution. The sizes shown here are for a 9 X 9 puzzle, the default. *
    * These sizes match the size of the puzzles and solutions supplied for this *
    * project. *
    \************************************************* ***************************/

    /* Size of a standard sudoku puzzle */
    #define ROWS 9
    #define COLS 9


    /************************************************** *********************
    * LoadPuzzle() is a high-level function that:
    * prompts the users for a filename
    * opens that file
    * reads the data into two ROWS X COLS arrays of ints passed into the
    * function, which are the original puzzle and its solution
    * closes the file
    *
    * INPUTS: two 9 X 9 arrays of ints, original & solution, and rows & cols
    * OUTPUT: none, but the arrays passed in are filled with the data
    * from the file requested
    ************************************************** ********************/

    void LoadPuzzle(int original[ROWS][COLS], int solution[ROWS][COLS], int rows,
    int cols);

  4. #4
    The C eater *munch*
    Join Date
    Oct 2006
    Posts
    101
    ic.... try this
    Code:
    LoadPuzzle(original, solution, ROWS, COLS)

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    5
    ....wow....hah...well I feel dumb. I could have sworn it was necessary to specifiy the size of the array when it gets passed into the function. Thank you yxunomei for the helpful and very fast reply. I greatly appreciate it!

  6. #6
    The C eater *munch*
    Join Date
    Oct 2006
    Posts
    101
    no worries

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. Replies: 6
    Last Post: 03-02-2005, 02:45 AM