compile printing a string function give error message - C

c, printf, string

Solution

You use `%S` format, whereas the format for strings (`char*`) is `%s`.

printf("%s - %s\n", a, b);

Problem

i want to write a simple main function in C that receive two line of string input and prints them on the screen. this is the code i wrote: ``` 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; } ``` and when i try to compile, i get this error message: ``` 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] ``` Thanks for helping

Original source