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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:57:12+00:00 2026-05-15T00:57:12+00:00

Trying to get some basic understanding of console functionalities. I am having issues so

  • 0

Trying to get some basic understanding of console functionalities. I am having issues so consider the following…

#include "stdafx.h"
#include<iostream>
#include<conio.h>

using namespace std;

/*
This is a template Project
*/

void MultiplicationTable(int x);

int main()
{

    int value = 0;

    printf("Please enter any number \n\n");
    getline(cin, value);

    MultiplicationTable(value);


    getchar();


    return 0;
}

I actually based this off code from http://www.cplusplus.com/doc/tutorial/basic_io/ . My IDE is not recognizing getline() so of course when I compile the application. I get an error

'getline': identifier not found

Now take a look at this code

#include "stdafx.h"
#include<iostream>
#include<conio.h>

using namespace std;

/*
This is a template Project
*/

void MultiplicationTable(int x);

int main()
{

    int value = 0;

    printf("Please enter any number \n\n");
    cin>>value;

    MultiplicationTable(value);


    getchar();


    return 0;
}

When I execute this line of code the console window opens and immediately closes. I think I a missing something about cin. I do know that it delimits spaces but I don’t know what else. what should I use for input to make my life easier.

  • 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-15T00:57:13+00:00Added an answer on May 15, 2026 at 12:57 am

    The function getline() is declared in the string header. So, you have to add #include <string>.
    It is defined as istream& getline ( istream& is, string& str );, but you call it with an int instead of a string object.

    About your second question:

    When I execute this line of code the console window opens and immediately closes

    There is probably still a '\n' character from your input in the stream, when your program reaches the function getchar() (which I assume you put there so your window doesn’t close). You have to flush your stream. An easy fix is, instead of getchar(), add the line

     int c;
     while((c = getchar()) != '\n'){} 
    

    This will flush your stream until the next line-break.

    Remark: conio.h is not part of the c++ standard and obsolete.

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

Sidebar

Related Questions

I am having a few issues trying to get some basic jquery functionality working
I am trying to get my head round some basic erlang functionality and I
I am new to jquery, with some basic understanding. I am trying to use
I'm trying to get some basic authentication/authorization with devise/cancan with Rails. Rather than using
So I'm trying to get some basic jQuery code with Rails working, but it
Trying to get some basic drag/drop functionality happening for an iPhone application. My current
I'm trying to get some basic ajax working on rails. I have a comon
I am new to Corona and am trying to get some basic OOP going
I am trying to get started with some basic Ocaml programming. To start I
Trying to get some initial bearings on useful processes that a basic working knowledge

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.