format '%s' expects argument of type 'char *'

c

Solution

`char st` is a single character. Judging by the rest of your code, you probably intended to declare an array of characters:

char st[80];

Problem

``` #include <stdio.h> int main(void) { int i,j,k; char st; printf("enter string\n"); scanf("%s", st); printf("the entered string is %s\n", st); } ``` Compiling above program gives me a warning: ``` warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat] palindrom.c:8:1: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat] ``` What am I doing wrong here? This is what happens when I run it: ``` $ ./a.out enter string kiaaa the entered string is (null) ``` Edit: Here is another version of the code (made `char st;` into `char *st`): ``` #include <stdio.h> int main(void) { int i,j,k; char *st; printf("enter string\n"); scanf("%s", st); printf("the entered string is %s\n", st); } ``` However, it behaves the same on runtime.

Original source