I'm trying to print out each element of a 2d char arrray in turn using this piece of code:
#include <stdio.h>
#include <stdlib.h>
char positions[3][3] = {'A', 'B', 'C', 'D', 'E', 'F','G', 'H', 'I'};
int main(){
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
printf("%s \n", &positions[i][j]);
}
}
return 0;
}
But the output is:
ABCDEFGHI
BCDEFGHI
CDEFGHI
DEFGHI
EFGHI
FGHI
GHI
HI
I
Instead of:
A
B
C
D
E
F
G
H
I
And I can't work out how to fix it. I've looked around and haven't been able to find any answers to this specfic issue. Any advice would be great. Thank you.