Recent Posts
printf("ho_tari\n");
stringArray 본문
#include <stdio.h>
void printStringArray1(const char (*pArr)[20], int size)
{
for (int i = 0; i < size; ++i)
{
printf("%s\n", &pArr[i][0]); // pArr[i]
}
}
void printStringArray2(char **pArr, int size)
{
for (int i = 0; i < size; ++i)
{
printf("%s\n", pArr[i]); // &pArr[i][0]
}
}
int main(void)
{
char cities1[][20] = {"Seoul", "Los Angeles", "Paris", "Rio de janeiro", "Moscow"};
printStringArray1(cities1, 5);
char *cities2[] = {"Seoul", "Los Angeles", "Paris", "Rio de janeiro", "Moscow"};
printf("\n");
printStringArray2(cities2, 5);
return 0;
}
<compile 결과>