すべてのstackoverflowユーザーの皆さん、こんにちは。私は、ファイルから読み取り、ファイルからの単語を動的に割り当てられた配列に格納する単純な(演習として)コードを作成しようとしています。私は間違ったマロッキングをしていると思います。誰かが私が間違っていることを見ていますか?
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#define ARRSIZE 10
int main(){
char * myArray = malloc(ARRSIZE*sizeof(char*));
FILE * p1File;
char mystring1 [100];
char word [100];
int j = 0;
p1File = fopen ("my1file.txt","r");
if (p1File == NULL) perror ("Error opening file");
else{
while(fgets(mystring1, 100, p1File)){
int nuRead = sscanf(mystring1, "%s", word);\
printf("lepo ani magia\n\n");
if (nuRead > 0){
strncpy (*myArray[j], mystring1, 100);
//*myArray[j] = mystring1;
}
j += 1;
}
}
}
///////////////////////////////////
my text file is
this
will
probably
work
but
I
am