hay guys iam new to c++ programming studing for c++.com
iam getting to a point that i wirte a program and it doesn't run
and i can't find anything realted to it , to know where is the problem so
that's the program

// cin with strings
#include <iostream>
#include <string>
#include <conio>
using namespace std;
int main ()
{
string mystr;
cout << "What's your name? ";
getline (cin, mystr);
cout << "Hello " << mystr << ".\n";
cout << "What is your favorite team? ";
getline (cin, mystr);
cout << "I like " << mystr << " too!\n";
getch();
}

iam compiling with borland and
the error

Error: noname00.cpp(9,21):Could not find a match for 'std::getline(istream_withassign,std::basic_string<char,std::string_char_traits<char>,std::allocator<char>>)'
Error: noname00.cpp(12,21):Could not find a match for 'std::getline(istream_withassign,std::basic_string<char,std::string_char_traits<char>,std::allocator<char>>)'

so what's the porblem ...
thanks in advance .

Recommended Answers

All 6 Replies

What verson of Borland compiler are you using? Many of the old 16-bit Borland compilers were created before the c++ standards and require *.h file extension

// cin with strings
#include <iostream.h>
#include <string.h>
#include <conio.h>
//using namespace std;
int main ()
{
string mystr;
cout << "What's your name? ";
getline (cin, mystr);
cout << "Hello " << mystr << ".\n";
cout << "What is your favorite team? ";
getline (cin, mystr);
cout << "I like " << mystr << " too!\n";
getch();
}

and if the problem with my compiler what compiler should i use .. or what's the most popular one ... I don't know ..
thanks for replying ...

For compilers have a look here

I like Visual Studio 2014, but it has a rather long and sometimes difficult learning curve. IMO the next best thing is Code::Blocks with MinGW compiler -- it's portable between *nix and MS-Windows where VS isn't.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.