Ok, please come to me with caution cause I'm a beginner and I'm not good in english but uhmm I'm having trouble creating the most important part of my scrabble game project. I'm trying to print a character but it always ends up being a weird symbol. I tried %s but it's giving me an error about STATUS_ACCESS_VIOLATION so i tried %c. I'm also having trouble initialize a char from the char array. I tried grid[i][j] = "a";, but it keeps saying assignment makes integer from pointer without a cast. So I'm temporarily turning into that just to test. I'm just testing this by the way b4 I go on for the real part.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include<stdio.h>
#include<string.h>
main(){
int choice;
char grid[12][12];
int i, j;
for(i=1; i<=12; i++){
for(j=1; j<=12; j++){
if (j==1 && i!=1);
grid[i][j] = (char)i;
printf("%c", grid[i][j]);
}
printf("\n\n");
}
}
So you mean I've got to put the value of the letter from the ASCII. What if I just want to put it as string since it's a char array anyway. Even if it's just a single char. %s is not working for me, it keeps saying status access violation.
Can you please give me the exact code.
Oh, and what if I want to print an integer as a char
So you mean I've got to put the value of the letter from the ASCII. What if I just want to put it as string since it's a char array anyway. Even if it's just a single char. %s is not working for me, it keeps saying status access violation.
Can you please give me the exact code.
Oh, and what if I want to print an integer as a char
I don't know whether this problem has been resolved. I just wanted to clarify a couple of points.
There is a difference between a character and a string. I think there may be some confusion between the two.
"s" is a string, while 'c' is a character - notice the difference between single and double quotes. Likewise, when using the C functions scanf() and printf(), %c means a character and %s means a string.
In more detail, the string "A" is actually an array of two characters, like this,