when I have a "table": 8*8 and i want to make a program that will change every '+' to 1, and everything else to 0. Example:
dkghft++
gfh++hfg
sad+fdg+
hgfh+gfh
+hfh++fg
++jk+ghj
++++++++
+5kjl+jk
and i want to get this:
00000011
00011000
00010001
00001000
10001100
11001000
11111111
10000100
So this is what I've done, but it's not working...
#include <stdio.h>
main(){
char r[7][7];
int a[7][7];
for(int i=0;i<8;i++)
{
scanf("%s",r[i]);
for(int j=0;j<8;j++)
{
if(r[i][j]=='+')a[i][j]=1;
else a[i][j]=0;
}
}
for(int i=0;i<8;i++)
{
printf("\n%s\n",r[i]);
for(int j=0;j<8;j++)
{
printf("%d",a[i][j]);
}
}
}
perhaps your dimensions need to be [8][8]
even tho you call values as 0-7 the number in the brackets when you declare the array needs to be the actual integer number of cells you want