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

  • Home
  • SEARCH
  • 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 8609129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:48:06+00:00 2026-06-12T03:48:06+00:00

I have a problem with a small C program. It outputs a question (see

  • 0

I have a problem with a small C program. It outputs a question (see code below) of which I can put input into (y and n) but then nothing else happens, even though it is meant to print something according to the input entered (y or n). However, nothing is outputted after my question, and the program just exits. Here is the code:

#include <stdio.h>

int main()
{
        char string [80];
        static char y;
        static char n;
        printf( "ARE YOU SHAQIRI? [y/n]: " );
        scanf( "%s", string );
        if ("%s" == "y")
                printf("That's impossible. YOU CANNOT BE SHAQIRI YOU IDIOT");
        else if ("%s" == "n")
              printf("I thought not.");
        fflush ( stdin );
        return 0;
}
  • 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-12T03:48:07+00:00Added an answer on June 12, 2026 at 3:48 am

    You have two problems in your comparison: if ("%s" == "y"):

    • "%s" is your scanf format string. If scanf succeeds in reading the input, then the result is in your variable: string.
    • Don’t use == to compare strings. You should use strcmp.

    Because you use a comparison of this form in both if tests, neither branch executes, and you see no output.

    Also don’t call fflush on stdin. You may intend fflush(stdout) there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: Have made a small mail program which works perfectly on my developer pc
I have a small problem which i can't seem to figure out. I tried
I have a small problem which i can't seem to solve myself. Look at
I have a small problem, but I hope somebody can help. Let's say that
I have a problem with Regular Expressions. I'm writing a small program that matches
I have a small C program to calculate hashes (for hash tables). The code
I have checked again and again for any problems in the code but can't
I'm having a small doubt in shell Scripting I have a program (a.out) which
I have a small program that is trying to wrap an NHibernate insert into
have small problem, and would very much appreciate help :) I should convert byte

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.