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 9252993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:06:07+00:00 2026-06-18T11:06:07+00:00

I wrote this test program to get the return value of the scanf() function.

  • 0

I wrote this test program to get the return value of the scanf() function.

however in the test, if i input a integer, the program is normal, but when i input a string, it will go into a endless loop. who can explain the reason for that?

another thing is that is the escape character \0 stand for the ascii code 0? when I print a “\12”, i will get a new line, but when I print “\9”, I couldn’t get a “TAB”(the TAB’s ascii code is 9).

#include <stdio.h>

int main(void){
    int x;
    int temp;
    //printf("\13");
    for(;;){
        temp=scanf("%d",&x);
        printf("%i",temp);
    }

}
  • 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-18T11:06:08+00:00Added an answer on June 18, 2026 at 11:06 am

    You’re telling scanf to read an integer. If you input a string the scanf will wait for an integer input. scanf also does not purge the input so it will read the same thing over and over again. You should check the value of temp when it successfully read something it will return the count of successful reads. In your case on the string input it should return 0.

    Also depending on where you output and the shell you use the tab output may or may not be ignored or interpreted differently.

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

Sidebar

Related Questions

I write this code to get Dunnet anova post hoc test import rpy2.robjects as
I wrote this code for zoom in/out . it works but even with one
I wrote this short program which has a tiny GUI. Its supposed to allow
I wrote this program: #include <stdio.h> /*Part B Write a program that: defines an
Here's a small test program I wrote: #include <iostream> using namespace std; class A
I have the following class hierarchy class Test { public string Name { get;
I am trying to understand the fundamentals of blocks. I wrote this simple test:
I wrote this Node class and = operator overload function and this is the
I'm trying to write a method like this: public static T Test<T>() { if
This is for Play! Framework 2.0. I'm trying to write a simple test case

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.