LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-27-2003, 08:17 AM   #1
rootyard
Member
 
Registered: Aug 2003
Posts: 167

Rep: Reputation: 30
question concerning cin.ignore


consider the following block:

------------------------------------------------------------------
if(new_rec_ptr != NULL) // If no error allocating memory, get data
{ // and insert node.
// Get name and phone number from the user.
cin.ignore(80,'\n');
cout << "\nEnter a new record.\n";
cout << "Last Name: ";
getline(cin,new_rec_ptr->last_name);
cout << "First Name: ";
getline(cin,new_rec_ptr->first_name);
cout << "Phone Number: ";
getline(cin,new_rec_ptr->phone_num);

insert_node(new_rec_ptr);
}
------------------------------------------------------------------

i have not seen the cin.ignore before... what does this line do?
 
Old 08-27-2003, 02:01 PM   #2
Mohsen
Member
 
Registered: Feb 2003
Location: Iran
Distribution: Solaris 10
Posts: 201

Rep: Reputation: 30
The ignore member function skips over a designated number of characters (default is one character) or terminates upon encountering a designed delimiter (the default delimiter is EOF which causes ignore to skip to the end of file when reading from a file).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ | cin.getline question... Mega Man X Programming 7 01-08-2004 10:34 AM
Stupid Question but don't ignore zinac3f Linux - Networking 3 10-16-2003 04:54 PM
cin.ignore Xiangbuilder Programming 4 10-08-2003 07:57 PM
g++ and cin.getline() codeviking Programming 8 07-03-2003 07:42 AM
cin.getline adam_boz Programming 6 10-02-2002 08:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration