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:

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)?

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

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...

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:

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.