Created
January 23, 2013 18:36
-
-
Save ahfoukou/4611376 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void save_puzzle(unsigned char board[][9]) | |
{ | |
int i, j, k; | |
char path[50]; | |
clrscr(); | |
printf("Insert the name of the file you want to save your sudoku puzzle \n"); | |
scanf("%s", path); | |
k = strlen(path); | |
FILE *file = fopen(path, "w+"); | |
if(!file) | |
{ | |
printf("The file you specified could not be opened for writing"); | |
return; | |
} | |
//apothikeuw xaraktira xaraktira sto arxeio keimenou kai meta allazw grammi wste na pari ti morfi opws ta arxeia pou mas dwsate px. easy1.sud | |
if (path[k] == 'd' && path[k-1] == 'u' && path[k-2] == 's' && path[k-3] == '.') { | |
for(i = 0; i < 9; i++) | |
{ | |
for(j = 0; j < 9; j++) | |
{ | |
fputc('0' + board[i][j], file); | |
} | |
fputc('\n', file); | |
} | |
fclose(file); | |
printf("Your sudoku puzzle was succesfully saved in file %s", path); | |
} | |
else printf("The file name must have a .sud suffix"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment