Need help fixing segmentation fault
I have to write a program for my class and I am having a bit of trouble with the file pointer.
Code:
#include <stdio.h>
#include <string.h>
int main(void) {
char stone_color[82];
char column[82];
int row[82];
int i;
int x;
FILE *fp;
fp = fopen("goboard1.txt", "r");
if ( fp == NULL ) {
printf(" Not a valid pointer! \n");
}
i == 0;
while( fscanf(fp, "%s", stone_color[i]) != EOF) {
fscanf(fp, "%s", column[i]);
fscanf(fp, "%d", row[i]);
i++; }
return (0);
}
This is what I have right now. It points to a file that has 3 columns of numbers/letters like this
b A 1
b B 4
B b 1
B C 2
B C 3
W A 3
w A 1
W B 3
W B 2
What I'm trying to do is scan those into arrays and later print them. The first column is stone_color the second is column and the third should be row. Everything compiles correctly and the file is valid and in the same directory however when I run it I get a segmentation fault. Any ideas?