Taking strings as a 2-D char array
Taking strings as a 2-D char array I want a code such that I enter some strings one-by-one (by pressing enter) and display it. for example; Input abc def Output abc def also I want this input to be in a array so that I can select any character from the array whenever I want. For example: s[1][1] gives 'e'. I have writen a code for this problem. #include <stdio.h> #include <stdlib.h> int main() { int i, j, n, m; scanf("%d%d", &n, &m); char a[n][m]; for (i = 0; i<n; i++) scanf("%s", a[i]); for (i = 0; i<n; i++) { printf("%s", a[i]); printf("n"); } } But for this code my input/output goes like this: Input ab cd Output abcd cd Can anyone tell where am I going wrong? The input you have shown in question is missing the input value of n and m . Show the input value you are giving to n and m . – H.S. Jun 2...
