【发布时间】:2018-12-12 10:43:06
【问题描述】:
为什么我应该在这里使用 %c 而不是 %s? 如果我使用 %s 会出错
printf("%c",Array[i]);
当我定义char Array[STRSIZE]="apple"; should use %s here
那么如何正确使用 %s 和 %c 呢?
代码:
#include<stdio.h>
#include<string.h>
int main(){
#define STRSIZE 81
char Array[STRSIZE];
printf("Enter a string: ");
gets(Array);
printf("\nYou entered: ");
int i ;
for(i=0;i<strlen(Array);i++){
printf("%c",Array[i]);
}
return 0 ;}
结果:
Enter a string: apple
You entered: apple
【问题讨论】:
-
检查类型!!