Hi there I am currently teaching myself C and I have to create a program with a 2d array that receives upto 5 names and prints them out. No pointers should be used :(. So I am wondering can anybody help me with this.
#include <stdio.h>
int main(int argc, const char * argv[])
{
char i2DArray[1][5];//1 Row and 5 columns
int x;
int y;
//Initializing the 2d array
for ( x = 0; x < 1 ; x++ ){
for ( y = 0; y < 5; y++){
printf("Enter the name of your friend: ");
scanf("%s", &i2DArray[x][y]);
}
}
//For loop for printing out the input
for ( x = 0; x < 1; x++ ){
for ( y = 0; y < 5; y++){
printf("\t%s", *i2DArray);
}
}
return 0;
}
This is the output I get Bleh :(. How can I print all the words in full? Please help I have searched everywhere
Enter the name of your friend: hello
Enter the name of your friend: there
Enter the name of your friend: people
Enter the name of your friend: I
Enter the name of your friend: know
htpIknow htpIknow htpIknow htpIknow htpIknowProgram ended with exit code: 0