943,479 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 22860
  • C++ RSS
Jun 17th, 2004
0

cin.getline

Expand Post »
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:
Similar Threads
Reputation Points: 12
Solved Threads: 0
Newbie Poster
MaxC is offline Offline
11 posts
since May 2004
Jun 17th, 2004
0

Re: question

Answer:
Use Google to find a reference.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Jun 17th, 2004
0

Re: question

Quote originally posted by Dave Sinkula ...
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)?
Reputation Points: 12
Solved Threads: 0
Newbie Poster
MaxC is offline Offline
11 posts
since May 2004
Jun 18th, 2004
0

Re: cin.getline

Choice ( A ) is the most accurate.There are more funtions getline can peform.
Reputation Points: 108
Solved Threads: 7
Posting Whiz in Training
FireNet is offline Offline
256 posts
since May 2004
Jun 18th, 2004
0

Re: cin.getline

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

Quote ...
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...
Reputation Points: 12
Solved Threads: 0
Newbie Poster
MaxC is offline Offline
11 posts
since May 2004
Jun 18th, 2004
0

Re: cin.getline

It should be answer (b)
Here's an example:
C++ Syntax (Toggle Plain Text)
  1. #include <iostream.h>
  2. main()
  3. {
  4. char s[100];
  5. cin.getline(s,100);
  6. cout<<s;
  7. }
So, cin.getline(char_array,max_lenght_of_array); :lol:
Reputation Points: 16
Solved Threads: 0
Light Poster
Fili is offline Offline
34 posts
since Jun 2004
Apr 22nd, 2005
0

Re: cin.getline

Quote originally posted by Fili ...
It should be answer (b)
Here's an example:
C++ Syntax (Toggle Plain Text)
  1. #include <iostream.h>
  2. main()
  3. {
  4. char s[100];
  5. cin.getline(s,100);
  6. cout<<s;
  7. }
So, cin.getline(char_array,max_lenght_of_array); :lol:
Thanks.
You have solved my problem
Reputation Points: 10
Solved Threads: 0
Newbie Poster
azeembutt is offline Offline
1 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: run code
Next Thread in C++ Forum Timeline: Please help with what '*' and '&' mean...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC