简体   繁体   中英

C scanf char array

my problem is that the printf does not get me any output. I'm totally confused. Any idea why?

#include <stdio.h>

int main(){

char var[50];
scanf_s("%s", var); // visual studio force me to use scanf_s
printf("In: %s\n", var); // the output is just 'In:'

system("PAUSE");
return 0;
}

scanf_s需要大小作为参数。

scanf_s("%s", var, 50);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM