Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #define SIZE 9
- typedef struct {
- int board[SIZE][SIZE];
- int *rows[SIZE];
- int *columns[SIZE];
- int *boxes[SIZE];
- } sudoku ;
- void readBoard(sudoku s, char *filename);
- void parseBoard(int board[][SIZE]);
- int main(int argc, char *argv[])
- {
- if(--argc > 0) {
- static sudoku mysudoku;
- readBoard(mysudoku, argv[1]);
- parseBoard(mysudoku.board);
- }
- else
- printf("Missing command line argument\n");
- }
- void readBoard(sudoku s, char *filename) {
- FILE *fp = fopen(filename, "r");
- for (int i = 0; i < SIZE; ++i) {
- for (int j = 0; j < SIZE; ++j) {
- char c = fgetc(fp);
- if (isdigit(c)) { //if number
- s.board[i][j] = atoi(&c);
- } else if(c == '.') { //if blank
- s.board[i][j] = 0;
- }
- }
- }
- fclose(fp);
- }
- void parseBoard(int board[][SIZE]) {
- printf("Hello");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement