Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7979723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:51:05+00:00 2026-06-04T09:51:05+00:00

#include <stdio.h> int main(void) { int i,j,k; char st; printf(enter string\n); scanf(%s, st); printf(the

  • 0
#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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:51:06+00:00Added an answer on June 4, 2026 at 9:51 am

    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];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include<stdio.h> void function(int); int main() { int x; printf(Enter x:); scanf(%d, &x); function(x); return
consider the code #include<stdio.h> int main(void) { char* a; scanf(%s,a);//&a and &a[0] give same
#include <string.h> #include <stdlib.h> #include <stdio.h> int main(void) { unsigned char *stole; unsigned char
#include<stdio.h> #include<conio.h> int main (void) { int a,b,c,d; clrscr(); a=3; b=5; c=a,b; d=(a,b); printf(c=%d,c);
#include<stdio.h> void foo(int **arr) { arr[1][1]++; } main() { int arr[20][20]; printf(%d\n,arr[1][1]); foo((int**)arr); printf(%d\n,arr[1][1]);
#include <stdio.h> #include <ctype.h> #define STRING_LEN 500 void stripspaces(char, char, char); int main(void) {
Source: #include <stdio.h> void main() { int i, j, tree_Size, spaces, total_Spaces, x; char
So basically: #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> int main(void){ //test strrev
My code #include <stdio.h> #include <stdlib.h> #include <ctype.h> void getData(short int *number, char *string)
This is my source code: #include <stdio.h> #include <string.h> void main() { int broj_znakova,i=0;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.