我想在C中寫一個簡單的主函數,接收兩行字符串輸入並將它們打印在屏幕上。 這是我寫的代碼:編譯打印字符串函數給出錯誤信息 - C
int main()
{
char a[100];
char b[100];
printf("Enter the first string:\n");
fgets(a,100,stdin);
printf("Enter the second string:\n");
fgets(b,100,stdin);
printf("\n\n THE FIRST STRING IS: %S\n\n THE SECOND STRING IS:%S",a, b);
return 0;
}
,當我嘗試編譯,我收到此錯誤信息:
gcc -g -Wall PN52.c -o myprog
PN52.c: In function ‘main’:
PN52.c:12:2: warning: format ‘%S’ expects argument of type ‘wchar_t *’, but argument 2 has type ‘char *’ [-Wformat]
PN52.c:12:2: warning: format ‘%S’ expects argument of type ‘wchar_t *’, but argument 3 has type ‘char *’ [-Wformat]
感謝您的幫助
請路過'-Wall'到'gcc'的好習慣! –