2021年1月4日星期一

differences between "percent c" and "percent s" in C

i have a code like this:

#include<stdio.h>

int main() {

char str[100];

int k;

scanf("%s",str);

scanf("%d",&k);

printf("%c",str[k-1]);

return 0; }

and can i ask u guys a question? Why in command printf we have to use "%c" instead of "%s"? I try replacing "%c" = "%s" but get no result. Thanks for your answer!

https://stackoverflow.com/questions/65572693/differences-between-percent-c-and-percent-s-in-c January 05, 2021 at 11:06AM

没有评论:

发表评论