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

  • Thanks..
    38 weeks 3 days ago
  • Hmmm,Interesting one,thx for
    39 weeks 4 days ago
  • Buyer beware
    40 weeks 3 days ago
  • REPLY:Actual Processes Involved
    40 weeks 4 days ago
  • Back to Ruby
    49 weeks 6 days ago
  • Links provided
    1 year 13 weeks ago
  • Module for wordpress to Drupal 6.x
    1 year 13 weeks ago
  • The wordpress plugin looks
    1 year 14 weeks ago
  • Good point..... You're
    1 year 14 weeks ago
  • Many thanks. If I'm going to
    1 year 14 weeks ago

New forum topics

  • Imported posts only visible to user1
  • 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
more

Sponsored links

Steve's Stuff
All about my running and from time to time other stuff

Improve Memory
All about memory techniques, excellent and relevant articles.

getline()

cin.getline (arrayname, size);

Submitted by Steve on Tue, 22 Apr, 2008 - 23: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.

  • Add new comment
  • Read more
  • 655 reads

 Subscribe in a reader

free hit counter


RoopleTheme