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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:28:55+00:00 2026-05-17T20:28:55+00:00

I’m an absolute beginner to programming and i’m just doing some exercises exercises for

  • 0

I’m an absolute beginner to programming and i’m just doing some exercises exercises for the beginning.

First of all, i’m using Visual C++ 2010 to compile C-Code. I just create a new project and choose an empty console application. After that, I create a ressource file named test.c and change in the file properties the elementype to C/C++ Compiler and compile as C++ Code, so that i can use #include <iostream> for the std::cin.get() command. Now the code:

#include <stdio.h>
#include <iostream>

int main() 
{
   int number1, number2;
   int sum;

   puts("Enter number 1 please:");
      scanf_s("%d",&number1);
   puts("Enter number 2 please:");
      scanf_s("%d",&number2);

   std::cin.get();
   std::cin.get();  //(1)

   sum = number1 + number2;
      printf("The average is %f\n", sum/2);

return 0; 
}

Now my problem ist that the “std::cin.get()” command is just ignored. Afer typing in the two numbers the program just stops and the console window closes.

Any idea where the problem is?

I have another question please.

Since my problem with holding the console open is solved (1), now my printf() gives me just zeros as output. I want to have a float number as output but no matter what i type in as number1 and number2 i always get “0.000000”.

Since i’m still working on my little program to verify the input before it is accepted, i have another question please.

I want to use the following code just to check the input.

#include <stdio.h>
#include <iostream>
#include <ctype.h>

int main() 
{
   int number1, number2;
   int sum;

   puts("Enter number 1 please:");
      scanf_s("%d",&number1);

   if (isdigit(number1)) 
   {
   puts("Enter number 2 please:");
      scanf_s("%d",&number2);
   }
   else 
   {
   puts("Your input is not correct. Enter a number please.");
   }

   std::cin.get();
   std::cin.get();

   /*



   sum = number1 + number2;
      printf("The average is %f\n", sum/2);  */

return 0; 
}

Well it doensn’t work. I type in a digit and my response is “Your input is not…”. I have used the search and found the following: Check if User Inputs a Letter or Number in C. Unfortunately the suggestions doesn’t help me.

  • 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-05-17T20:28:55+00:00Added an answer on May 17, 2026 at 8:28 pm

    It’s not ignored. When you type your second number, then hit enter, it puts your number plus a newline character in the input stream. scanf removes the number, but leaves the newline character alone. When you call cin.get(), since there’s a character in the stream, it doesn’t wait for your input.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

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.