Hello, I'm new to C language, and I'm using Visual C as my compiler..
Here's my code:
#include <stdio.h>#include <stdlib.h>
#include <Windows.h>
int i[8][8];
void main(){
int row;
int col;
for(row=0;row<=7;row++)
{
for(col=0;col<=7;col++)
{
i[row][col]=0;
}
}
printi();
getchar();getchar();
}
int printi()
{
char s[500];
int row;
int col;
int g;
int a=0;
for ( row=0; row < 7; row++ )
{
for ( col=0; col < 7; col++ )
{
s[a]=("%c", (char)i[row][col] );
a++;
}
}
for(g=0;g<=sizeof(s);g++)
{
int a=0;
if(a<8){
printf("%c",s[g]);
printf(" ");
}
else{
a=0;
printf("\n");
}
}
return 0;
}
I want it to give this output:
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
But it gives me a weird set of characters that are not letters or numbers.. only weird symbols.. can u fix the code for me please and explain the problem?
Thanks in advance