“生成错误”错误-1073741819 - C [英] `Build Error` Error -1073741819 - C
问题描述
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b IOSSET
NWEGHE
BOOJAB
UIENES
PSAFKF
IUNHM Qu
YRDVEL
VEHWHR
IOTMUC
TYELTR
STITYD
AGAEEN
每个骰子需要6个字母,在一个链表中。当我试图运行下面的代码,我不断收到错误代码: C:\Dev-Cpp\Makefile.win [Build Error] [Untitled1.o] Error -1073741819
我尝试过使用3个不同的IDE,但总是看起来会遇到一些编译问题。我似乎无法弄清楚我要去哪里错了!这还不是完整的,但是在我继续深入下去之前,宁愿搞清楚。
$ b
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);
返回0;
readData(struct boggleDataNode temp){
//初始化变量包括
//打开输入文件
FILE * input = fopen(BoggleData.txt , R);
int name = 0;
int id = 0;
char数据[96] = {};
检查文件是否打开
if(input == NULL){
fprintf(stderr,Can not open input file!\\\
);
exit(1);
while(fscanf(input,%s,& data)!= EOF)
printf(%s,data);
$ b $ / code $ / pre
解决方案代码,更改
struct boggleDataNode {
char data [3];
struct boggleDataNode * nextData;
} * head;
到
struct boggleDataNode {
char data [3];
struct boggleDataNode * nextData;
};
好像你不需要这个结构的全局指针。根据你的使用情况,它将被本地的头
遮蔽。
接下来,你分配 NULL
也是。
> >指向本身,而不是指向指向的变量。 (FWIW, NULL
本身是一个指针,虽然是一个无效的指针)。
Change
* head = NULL;
到
head = NULL;
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;
这篇关于“生成错误”错误-1073741819 - C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!