为什么我应该在这里使用%c而不是%s?如果我使用%s将错误
printf("%c",Array[i]);
Run Code Online (Sandbox Code Playgroud)
当我定义 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 ;}
Run Code Online (Sandbox Code Playgroud)
结果:
Enter a string: apple
You entered: apple
Run Code Online (Sandbox Code Playgroud)