Originally Posted by
Salem
> scanf("%s",matrix[i]);
The problem here is you're reading a string, not a char.
Perhaps
scanf(" %c",&matrix[i][j]);
Yup, tried that. Doesn't work either.
Code:
#include<stdio.h>
main()
{
char **matrix;
int i,j;
int row,col;
printf ("Rows: ");
scanf ("%d",&row);
printf ("\nColumns: ");
scanf ("%d",&col);
matrix=(char**)calloc(row,sizeof(char*));
for(i=0;i<col;i++)
matrix[i]=(char*)calloc(col,sizeof(char));
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
scanf("%c",&matrix[i][j]);
if(matrix[i][j]==matrix[0][col-1])
printf("Top right corner is: %c\n",matrix[i][j]);
}
}
Doesn't really work properly as the integer one I made