Hey,
this is a simple program that reads the first number read in a file, and depending on it will display a certain message... If I try to printf the size, then it will display it with no problems, it is only when I apply the switch and if loop that I get segmentation error..?? help please!!
Code:
#include <stdlib.h>
#include <stdio.h>
int main()
{
FILE* data;
data=fopen("Problem_File.dat","r");
int i,j;
int data_buffer[i][j]; /* Create array */
int size;
int *pa;
int x;
int square;
int block;
fscanf(data,"%i", &(data_buffer)); /* Scan in Sudoku Values */
pa=&(data_buffer[0][0]); /* Pointer points at contents at [0][0] */
size=*pa; /* Put contents of pointer into (size)*/
switch(size) /* Set messages & error messages for user */
{
case 1:
printf("Error - A 1x1 Sudoku is pointless, my friend\n");
return 0;
case 2:
printf("Using a 2x2 Sudoku\n");
break;
case 3:
printf("Using a 3x3 Sudoku\n");
break;
case 4:
printf("Using a 4x4 Sudoku\n");
break;
}
return 0;
}