c - Pointer to multi-dimensional array -
i don't know what's problem piece of code, i'm getting random result here:
#include <stdio.h> #include <conio.h> int main() { char arr[3][2] = {{'z','a'},{'e','r'},{'x','v'}}; int i; scanf("%d",&i); printf("%c",*(arr+i)); getch(); } thanks
first of not clear trying do. can suggest change statement
printf("%c",*(arr+i)); the following way
printf("%c",**(arr+i)); in case if in range 0 - 2 statement output first character of corresponding row. example equal tp 1 output be
e if want output character in array using index use
printf("%c", *( *arr + )); or
for ( int = 0; < 6; i++ ) printf("%c", *( *arr + ));
Comments
Post a Comment