my assignment is to take in a data file of all the possible letters for each die from the game Boggle. Here's a copy of the data file:
D R L X E I
C P O H S A
N H N L Z R
W T O O T A
I O S S E T
N W E G H E
B O O J A B
U I E N E S
P S A F K F
I U N H M Qu
Y R D V E L
V E H W H R
I O T M U C
T Y E L T R
S T I T Y D
A G A E E N
Each die takes 6 of the letters, and these are stored in a linked list. When I have tried to run the following code, I keep getting an error code: C:\Dev-Cpp\Makefile.win [Build Error] [Untitled1.o] Error -1073741819
I've tried using 3 different IDEs, but always seem to get some compiling issue. I can't seem to figure out where I'm going wrong! This isn't complete yet by any means but would rather figure this out before I keep going deeper and deeper. Thanks in advance!
code:
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define LENGTH 80
struct boggleDataNode{
char data[3];
struct boggleDataNode *nextData;
}*head;
struct boggleDieSideNode{
char dieSideData[3];
struct boggleDieSideNode *nextSide;
}*head1;
void readData(struct boggleDataNode temp);
int main(){
int counter = 0;
struct boggleDataNode *head;
struct boggleDieSideNode *head1;
struct boggleDataNode *temp;
*head = NULL;
*head1 = NULL;
*temp = *head;
readData(*temp);
system("pause");
return 0;
}
void readData(struct boggleDataNode temp){
//initializing variables including
//opening the input file
FILE *input = fopen("BoggleData.txt","r");
int name =0;
int id=0;
char data[96] ={};
//error checking that the file opened
if (input == NULL){
fprintf(stderr, "Can't open input file!\n");
exit(1);
}
while( fscanf(input, "%s", &data) != EOF)
printf("%s", data);
}
In your code, change
struct boggleDataNode{
char data[3];
struct boggleDataNode *nextData;
}*head;
to
struct boggleDataNode{
char data[3];
struct boggleDataNode *nextData;
};
as it seems you don't need a global pointer for that structure anyway. As per your usage, it will be shadowed by the local head.
Same goes for head1 also.
Next, you assign NULL to a pointer itself, not to the variable it points to. (FWIW, NULL itself is a pointer, an invalid one, though).
Change
*head = NULL;
to
head = NULL;