Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

New to C++ (getline) in borland

Name: Newbie Programmer 2008-01-12 21:51

I'm new to C++. I'm trying to use "getline" in my program to accept character and whitespace inbetween but I get some error in Borland.

/* This program defines class GradeBook with a
member function that takes a parameter; */

#include <iostream>
#include <string>
#include <conio.h>

class GradeBook
{
public:

    void displaymessage (string coursename)
    {
    cout << "\nWelcome to the Grade Book System\n\nThe name of your course is " << coursename <<endl;
    }
};


int main ()
{
   string NameOfCourse;
   GradeBook mygradebook;

   cout << "Please Enter the name of your course: " <<endl;
   getline (cin, NameOfCourse);  /* "Call to undefined function 'getline' error" */

    // cin >> NameOfCourse; //White space ends insertion operator

   mygradebook.displaymessage (NameOfCourse);

   getch();
   return 0;
}

Name: Anonymous 2008-01-12 22:02

>but I get some error in Borland.
I was going to read the rest of your post til I got to this. What error?

NO EXCEPTION

Name: Anonymous 2008-01-12 22:13

I'm new to C++
I was going to read the rest of your post til I got to this.

Name: Anonymous 2008-01-12 22:13

getch()
GTFO

Name: Anonymous 2008-01-12 22:14

These motherfuckers aren't going to help you.
Keep putting in effort.

Name: Anonymous 2008-01-12 22:23

>>1
What version of Borland?

Name: Anonymous 2008-01-12 22:28

>>6
Borland C++ 5.02

Name: Anonymous 2008-01-12 22:29

Compiles fine in the free one at http://cc.codegear.com/Free.aspx?id=24778 (after adding using namespace std;)

Name: Anonymous 2008-01-12 22:31

>>7
And the error?

Name: Anonymous 2008-01-12 22:38

>>8
I specified Borland for a reason.

>>9
"Call to undefined function 'getline' error"

Name: Anonymous 2008-01-12 22:39

>>10
If you follow the link, you'll see that it is Borland C++ 5.5.1

Name: Anonymous 2008-01-12 22:42

>>10
Add this after your includes: using namespace std;

Name: Anonymous 2008-01-12 22:45

>>12
I get this error:

Error:  parameter.cpp(28,31):Could not find a match for 'std::getline(istream_withassign,std::basic_string<char,std::string_char_traits<char>,std::allocator<char>>)'

Name: Anonymous 2008-01-12 22:50

>>13
It might be that that version of Borland C++ doesn't accept the two-parameter getline (check your API docs), so try this instead: getline(cin, NameOfCourse, '\n');

Name: Anonymous 2008-01-12 23:00

>>14
 getline(cin, NameOfCourse, '\n');

Worked. Not sure why but I can now use the getline function.

My version of Borland is outdated?

Name: Anonymous 2008-01-12 23:07

>>15
Yeah, it's from early 1997, and C++ was standardized in 1998, so that's probably why it's not quite right in places, e.g. getline.

Name: Anonymous 2008-01-12 23:22

>>16
I'm looking but I can't seem to find a borland 5.5 torrent.

Name: Anonymous 2008-01-12 23:40

>>17
PROTIP: Borland is an outdated piece of shit. Use GCC instead (http://gcc.gnu.org/). If, for some weird fucking reason (OH GOD OPTIMIZED?!) you feel the need to use that piece of shit bcc, you can download it for FREE here: http://dn.codegear.com/article/20633.

Name: Anonymous 2008-01-15 19:49

lol progfind


# progfind shiichan

Title:     Shiichan Post Referencing
URL:       http://dis.4chan.org/read/prog/1195857400
Posted:    2007-11-23 22:36
Last Post: 2007-11-24 14:52

Title:     SHIICHAN HAS A FATAL FLAW
URL:       http://dis.4chan.org/read/prog/1185843497
Posted:    2007-07-31 01:58
Last Post: 2007-08-03 12:56

Title:     Shiichan, read.php, Line 11
URL:       http://dis.4chan.org/read/prog/1185626900
Posted:    2007-07-28 13:48
Last Post: 2007-07-28 14:10

Title:     Shiichan needs an [img]
URL:       http://dis.4chan.org/read/prog/1185463229
Posted:    2007-07-26 16:20
Last Post: 2007-07-26 23:17

Title:     Shiichan
URL:       http://dis.4chan.org/read/prog/1181486959
Posted:    2007-06-10 15:49
Last Post: 2007-06-11 16:53

Name: Anonymous 2009-03-18 3:31

I wants lots and lots of some delectable pot!

Marijuana MUST be legalized.

Name: Anonymous 2011-02-16 18:27

>>20
back to /lounge/, please
>>22 nice dubs

Name: Anonymous 2011-02-16 18:27

>>21
thanks bro

also check 'em

Don't change these.
Name: Email:
Entire Thread Thread List