954,124 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

cin.getline

Hello all,

what do you think the answer following question is?

The cin.getline function:

a) reads a fixed number of characters as a string into a character array.

b) reads a line as a string into a character array.

c) reads a string up to the first blank space.

d) reads a character into an array

Answer:

MaxC
Newbie Poster
11 posts since May 2004
Reputation Points: 12
Solved Threads: 0
 

Answer:
Use Google to find a reference .

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 
Answer: Use Google to find a reference .

I already had but still a bit confused about the questions.
Ok, I think the answer is a), but why not b)?

MaxC
Newbie Poster
11 posts since May 2004
Reputation Points: 12
Solved Threads: 0
 

Choice ( A ) is the most accurate.There are more funtions getline can peform.

FireNet
Posting Whiz in Training
258 posts since May 2004
Reputation Points: 108
Solved Threads: 7
 

I have another question if you dont mind me asking - (last one).

The arguments to the cin.getline function should be

a. format string and the buffer size.

b. character array and the array size. :?:

If (b) was -array name and the array size- it would be accurate(?)
I think is (a) even if I dont quite understand why.

I dont write these questions.
Thanks for the replies...

MaxC
Newbie Poster
11 posts since May 2004
Reputation Points: 12
Solved Threads: 0
 

It should be answer (b)
Here's an example:

#include <iostream.h>
main()
{
   char s[100];
   cin.getline(s,100);
   cout<<s; 
}

So, cin.getline(char_array,max_lenght_of_array); :lol:

Fili
Light Poster
34 posts since Jun 2004
Reputation Points: 16
Solved Threads: 0
 

It should be answer (b) Here's an example:

#include <iostream.h>
main()
{
   char s[100];
   cin.getline(s,100);
   cout<<s; 
}

So, cin.getline(char_array,max_lenght_of_array); :lol:


Thanks.
You have solved my problem

azeembutt
Newbie Poster
1 post since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You