我是一个相对较新的程序员,我正在从事一个学校项目。现在我正在尝试做的是读取一个文件,并检查两个字符是否相互作用(即它们出现在同一行上)。
现在我没有做太多工作,我真的要求更多的想法而不是代码。怎么会做这样的事情?我有一些想法,但没有一个实际上在实践中工作,所以现在,这就是我真正做的和工作:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Characters{
char names[65][50]; //This is the names array
char compnames[65][50]; //This is a duplicate to compare the arrays of characters
int relations;
};
void NameFun();
int main(){
NameFun();
}
void NameFun(){
int i=0, choice;
struct Characters c;
FILE *fp = NULL;
fp = fopen("MisNames.txt", "r");
for(i=0; i<65; i++){
fgets(c.names[i], sizeof(c.names[i]), fp); //Gets each name and stores it as an element of an array
strcpy(c.compnames[i], c.names[i]); //For the duplicate, copying the elements
}
/*The rest of this was for testing purposes and has no real relevance
printf("What number name would you like to know about?\n");
scanf("%d", &choice);
choice = choice--;
printf("\t\t\t%s\n\n", c.names[choice]);
fclose(fp);
}*/