配列から関数に文字列を渡すにはどうすればよいですか?"Battleship"
関数print()
などに文字列を渡して出力させたい"Where would you like to place the Battleship?"
#include <stdio.h>
void print(char ship_names);
int main (void)
{
int index = 0;
char ships_name[5][21]= { "Aircraft Carrier (5)", "Battleship (4)", "Submarine (3)",
"Cruiser (3)", "Destroyer (2)"};
for(index = 0; index < 5; index++)
print(*ships_name[index]);
return 0;
}
void print(char ship_names)
{
printf("Where would you like to place the %s?\n", ship_names);
}