Passing Argument

Discussion in 'Mac Programming' started by ktalebian, Nov 29, 2008.

  1. ktalebian macrumors regular

    Joined:
    Dec 25, 2007
    #1
    Hi there,
    I have written a code in C. Using a makefile, I simply compiled it:

    sudoku_solver: sudoku.c
    gcc sudoku.c -o sudoku_solver

    now, how can I pass an argument (this argument is the name of the file where a sudoku puzzle is saved (i.e. like puzzles.txt)) to my compiled file from the command line?

    Thanks!
     
  2. MacRumors Guy macrumors member

    Joined:
    Sep 17, 2008
    #2
    Go inside the compiled program folder and then type:

    ./sudoku_solver puzzles.txt this way puzzles.txt will be the second element of your args array.
     

Share This Page