我正在尝试输出包含用户输入的数组的所有元素。例如,如果用户为形容词输入微笑、快乐和悲伤,我想将其输出给用户。
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int counter_1, counter_2, counter_3, tracker;
printf("Enter a number of adjectives: ");
int numAdj;
scanf("%d", &numAdj);
printf("Enter a number of nouns: ");
int numNouns;
scanf("%d", &numNouns);
char adj[numAdj];
char nouns[numNouns];
printf("Please enter %d adjectives: \n", numAdj);
for (counter_1 = 0; counter_1 <= numAdj - 1; counter_1++) {
scanf("%s", &adj[counter_1]);
}
printf("Please enter %d nouns: \n", numNouns);
for (counter_2 = 0; counter_2 <= numNouns - 1; counter_2++) {
scanf("%s", &nouns[counter_2]);
}
for (counter_3 = 0; counter_3 <= numAdj - 1; counter_3++) {
printf("%s", &adj[counter_3]);
}
return 0;
}
我不知道为什么我不能输出数组的数据。