better understanding of getline() and cin
        Posted  
        
            by numerical25
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by numerical25
        
        
        
        Published on 2010-05-26T16:49:18Z
        Indexed on 
            2010/05/26
            16:51 UTC
        
        
        Read the original article
        Hit count: 247
        
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.
© Stack Overflow or respective owner