Prime 357

We'll learn something

Site Menu

  • Home
  • Recent Posts
  • Forum
    • Programming Languages
      • C++
    • Website Design & Content Management
      • Wordpress >> Drupal
  • Blogs
  • Topics
    • C++
    • Changing hosts - Dummies Guide
    • Wordpress >> Drupal
  • Download Centre
  • Contact us
Home


Image - OpenID

User login

What is OpenID?
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password

Navigation

  • Recent posts

Topics

  • C++ (The Book)
  • Changing Hosts - a Dummies Guide
  • Wordpress to Drupal

Recent comments

  • Got it solved This page here
    3 hours 49 min ago
  • Links working
    1 day 3 hours ago
  • Thanks... I may be able to
    1 day 9 hours ago
  • 3306 by default
    1 day 19 hours ago
  • Is this the right place to
    1 day 20 hours ago
  • Figured
    3 weeks 6 days ago
  • I'm guessing at this stage
    3 weeks 6 days ago
  • WordPress MU?
    4 weeks 4 hours ago
  • Thanks
    10 weeks 1 day ago
  • I'm running the conversion
    11 weeks 5 days ago

New forum topics

  • What should the port number be
  • WordPress MU?
  • funny little bug in mac version
  • Error: Unable to Insert into Node_revisions table when converting from wordpress 2.6.0 to drupal 6.4
  • index.php?
more

Who's online

There are currently 0 users and 2 guests online.

Who's new

  • oODeathStormOo
  • leruffiant
  • Emtee
  • mnogodet
  • ZioMimmo

getline()

cin.getline (arrayname, size);

Submitted by Steve on Wed, 23 Apr, 2008 - 00:29
  • C++
  • cin
  • get()
  • getline()

So you want to read an entire line from the keyboard and not be bothered with cin >> getdata; only reading the first word. Then this form of the cin object is for you.

cin.getline(arrayname, size);

This form accepts an entire line entered from the keyboard terminated by the 'ENTER' key. The newline character created by the 'ENTER' key is replaced by a null '\0' character (which is the terminating character required for character arrays). As you can guess from the code snippet, the line of text is ultimately assigned to arrayname variable, a character array, and only receives the number of characters specified by the second parameter, size.

If the number of characters entered is greater than the number specified by the second parameter size the left-over characters remain in the input queue/stream. Remember, the next cin operation will retrieve either some or all of these characters depending upon the type of cin operation that's applied. If the number of characters is less than the parameter size then the input queue is effectively flushed and will not be a problem for the next cin operation.

  • Login or register to post comments
  • Read more
  • 248 reads

 Subscribe in a reader

free hit counter


RoopleTheme