Ok first of what Im going for is this.There are 12 columns and 15 rows so the line lenght is 12
Enter the line 1 of the puzzle:XTZMQYKCECFH---->12 chars
Enter the line 2 of the puzzle:SHOUTEXOEAPI
Enter the line 3 of the puzzle:XGTLQBELTNFK
'
'
'
Enter the line 15 of the puzzle:
So then ı take the input to another func to print the matrix and should be like this:
X T Z M Q Y K C E C F H
S H O U T E X O E A P I
X G T L Q B E L T N F K
'''
'''
'''
So here is the code but ı dont think it will work with scanf maybe ı should use gets()? I thought of just taking the line, storing it in another array and then tranferring into the matrix. Please try not to use any other library then stdio.h because the challenge is to do it not using prebuild string functions
#include <stdio.h>
#define COLUNM 12
#define ROW 15
void printPuzzle(char matrix[ROW][COLUNM]){
int i,j;
for (i=0;i<ROW;i++){
for(j=0;j<COLUNM;j++){
printf("\n");
printf("%3c",matrix[i][j]); }
}
}
int main (){
int i,j;
j=0;
char matrix[ROW][COLUNM];
for(i = 1 ; i < COLUNM+1 ; i++){
printf("Enter line %d of the puzzle :\n",i);
scanf("%s",matrix[j][i]);
j++;
}
printPuzzle(matrix[ROW][COLUNM]);
return 0;
}
I have thought of this as well for the main func:
int main (){
int i,j;
char line[COLUNM+1];
char matrix[ROW][COLUNM];
for(i = 0 ; i < ROW ; i++){
printf("Enter line %d of the puzzle :\n",i+1);
scanf("%s",line[i]);
for(j=0;j<COLUNM;j++){
matrix[i][j]=line[j];
}
}
printPuzzle(matrix[ROW][COLUNM]);
return 0;
}
But ı keep getting these warnings 30 | printPuzzle(matrix[ROW][COLUNM]); warning: passing argument 1 of ‘printPuzzle’ makes pointer from integer without a cast
.c:5:23: note: expected ‘char (*)[12]’ but argument is of type ‘char’ 5 | void printPuzzle(char matrix[ROW][COLUNM]){
Dont know much about c can someone explain in plain English