'Transferring data read from Txt to 2D array in C [closed]
#include <stdio.h>
int main() {
char newString[60][48];
FILE *ptr_readfile;
char line [128];
int filecounter=1, linecounter=1;
ptr_readfile = fopen("dhcpkayit.txt","r");
if (!ptr_readfile)
return 1;
while (fgets(line, sizeof line, ptr_readfile)!=NULL) {
for (int i = 0; i < 60; i++)
for (int j = 0; j < 48; j++)
newString[i][j]=*line;
printf("%s\n", line);
linecounter++;
}
fclose(ptr_readfile);
return 0;
}
Hello, I want to read all the words from the txt file and transfer them into a matrix (2 dimensional array). newString[j]=*line; I'm getting an error in this part. Can you help me if I ask friends who know C?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
