GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 124 of 203    Print  
what is the difference b/w get() and getline().

  
Total Answers and Comments: 1 Last Update: March 27, 2007     Asked by: mohit & dev 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: mysteriousgal
 
get() function fetches a character inlcuding the tab,blank space & newline  character.
 ex-
char c;
cin.get(c);

now if i write say Mysterious Girl.... it will first fetch M and assign it to c.
Then i have to put it in a loop to obtain the rest of the characters .


getline() function reads a whole line of text that ends with a newline character or RETURN key.

char c[20];
cin.getline(c,20);

now if i write mysterious gal...

it will get saved in array c.

smiles :)
mysterious gal

Above answer was rated as good by the following members:
yzesong
March 27, 2007 06:14:55   #1  
mysteriousgal        

RE: what is the difference b/w get() and getline().
get() function fetches a character inlcuding the tab blank space & newline character.
ex-
char c;
cin.get(c);

now if i write say Mysterious Girl.... it will first fetch M and assign it to c.
Then i have to put it in a loop to obtain the rest of the characters .


getline() function reads a whole line of text that ends with a newline character or RETURN key.

char c[20];
cin.getline(c 20);

now if i write mysterious gal...

it will get saved in array c.

smiles :)
mysterious gal

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    

 Related Questions

 Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. 
Latest Answer : You cannot use inline functions in a structure ...

 Classes and objects are separate but related concepts. Every object belongs to a class and every class contains one or more related objects.  Ø      A Class 
Latest Answer : Class is a combination of data member & member function where object is used for calling function In class we declare In object we call ...

The free subroutine frees a block of memory previously allocated by the malloc subroutine. Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, 
Latest Answer : free() - releases the memory of the pointer passed as parameter, to the OS/application consumption. Using the pointer after free() will result in undefinded resultsrealloc() - used to resize the memory held by the pointer to the number of bytes specificed. ...

Templates allow to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until certain point they fulfill 
Latest Answer : A template parameter is a special kind of parameter that can be used to pass a type as argument: just like regular function parameters can be used to pass values to a function, template parameters allow to pass also types to a function. These function ...

Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching 
Latest Answer : Virtual constructor is not build-in C++ feature but it doesn't mean its not used by devs in code and in conversations. There are many other things that doesn't exist in particular language yet, people find ways around to solve it (SingleTon, Virtual Constructor, ...

There is only one difference ,in classes the members are private by default whereas it is not so in structures. 
Latest Answer : There are a lot of differences between Structure & Class in C.But in C++ the only difference is the members structure are by default public where as class members are by default private.Using C++ structure we can do the OOPS concepts like inheritance ...

Latest Answer : New operator allows to allocate a memory from the heap, so a new instance of a class is created but operator New is used to overload the (new) operator just like overloading of other operators. Additionally: The term "operator new" is ...
Read Answers (5) | Asked by : suman

Latest Answer : C does not have limitation access. Structures in C are used to regroup data from different types.In C++ structure have limitation access propreties (private,public protected) with public access as default, can contain methods and can be used as a class. ...
Read Answers (10) | Asked by : suji

Latest Answer : All the above answers are right this is one more refinement.overridding is runtime polymorphism while overloading is compile time polymorphism.  ...
Read Answers (3) | Asked by : suji

Latest Answer : Inspite of repeated requests by some (few) sensible people to everybody to read the question properly before responding, nobody listens.For doreen, the question does not ask you to explain deep copy and shallow copy mechanism neither does is asks how ...
Read Answers (3) | Asked by : suji


 Sponsored Links

 
Related Articles

Concepts of Object-Oriented Programming

Object Oriented JavaScript In this chapter you ll learn about OOP Object Oriented Programming and how it relates to JavaScript As an ASP NET developer you probably have some experience working with objects and you may even be familiar with concepts such as inheritance However unless you re already a
 

What is difference between call by value and call by reference in function?

The arguments passed to function can be of two types 1. Values passed 2. Address passed The first type refers to call by value and the second type refers to call by reference. For instance consider program1 main() { int x=50, y=70; interchange(x,y); printf(“x=%d y=%d”,x,
 

SQL Programming

SQL Programming Overview Anybody who has done something for a long time has probably wanted to change how things work at some point or another. A worker at a mill might have found a more efficient way of cutting logs, or a mathematics teacher might have had a hand in changing a school’s al
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

WinRunner Programming Concepts

If you want to create WinRunner scripts that are highly efficient, there are important programming concepts that you will want to become familiar with. Understanding these concepts will provide you with a large number of key benefits. In addition to understanding these concepts, you must also learn
 

Programming Languages Certification

IT Certification programs have several options that will offer you the best knowledge.  By learning everything that you need to know about information technology you will be able to open new doors to your career and personal business desires.  IT Certification offers several vari
 

Neuro-linguistic Programming Methods

Neuro linguistic Programming Methods There are several methods used for performing Neuro linguistic Programming on an individual for obtaining insights into the psyche of the person in order to correct to modify certain patterns of behavior These techniques are also used for Neuro linguistic trainin
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

The Difficult Past of Neuro-linguistic programming

The Difficult Past of Neuro linguistic programming Neuro linguistic programming has had a rocky past with a number of lawsuits rivalry unsystematic development and intermittent progress During the 1980s the two founders separated after the lawsuit filed by Bandler Bandler went on to file several law
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape