Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ktalebian

macrumors regular
Original poster
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!
 
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!

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.