/* * Example of string declaration, initialization, output */ #include int main() { char str1[20] = "November 10, 2008"; char str2[10] = "November 10, 2008"; char president[]="George Washington"; char presidents[4][20]={"George Washington","John Adams", "Thomas Jefferson","James Madison"}; int i; printf("%s\n",str1); printf("\n"); printf("%s\n",str2); printf("\n"); printf("%s\n",president); printf("\n"); printf("%30s\n",president); /* right-justified */ printf("\n"); printf("%-30s\n",president); /* left-justified */ printf("\n"); /* right-justified */ for (i = 0; i<4; i++) printf("%30s\n",presidents[i]); printf("\n"); /* left-justified */ for (i = 0; i<4; i++) printf("%-30s\n",presidents[i]); return 0; }