I'm having troubles with the following code
#include <stdio.h>
#include <ctype.h>
int main (void) {
int i=0,j=0,row;
char str1[5], str2[5];
char machine[4][5]={0};
FILE *fp;
fp = fopen("text.txt","r");
while (fscanf(fp,"%s %s",&str1,&str2) == 2 ) {
row = str1[1];
while (str2[i] != NULL) {
machine[row][i]=str2[i];
i++;
}
}
for (i=0;i<5;i++)
for (j=0;j<5;j++)
printf("%s\n",machine[i][j]);
}
And i have a text files containing data in the following format
Z2 abcde
Z1 vwxyz
Z3 qrstu
What I'm trying to accomplish is to assign the characters into a character array into the form,
[v][w][x][y][z]
[a][c][d][e]
[q][r][s][t]
The above code showed that all are null rather than what it should be
Any insights?