By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

declaring cin.getline() vs getline()

P: 12
what is the difference between the cin.getline() function and getline() function?
Mar 12 '07 #1
Share this Question
Share on Google+
6 Replies


sicarie
Expert Mod 2.5K+
P: 4,677
What is the difference between the cin.getline() function and getline() function?
In one you explicitly declare the cin stream.
Mar 12 '07 #2

RedSon
Expert 5K+
P: 5,000
Nothing except one version you explicitly call it on the cin stream whereas the other is implicit.
Mar 12 '07 #3

P: 12
Can you initialize C++ string from C-string? and
Can you initialize C-string from C++ string?
Mar 12 '07 #4

sicarie
Expert Mod 2.5K+
P: 4,677
Can you initialize C++ string from C-string? and
Can you initialize C-string from C++ string?
I have merged these threads, and changed the title to better explain the problem
Mar 12 '07 #5

Ganon11
Expert 2.5K+
P: 3,652
I'm pretty sure you can create a C++ string (std::string) using a cstring as its parameter - something like:

Expand|Select|Wrap|Line Numbers
  1. char mycstr[20] = "Hello Guys!\0";
  2. std::string mystr(mycstr);
As for making a cstring from an std::string, there may be a function within std::string to return the character array, or you could simply create your own by iterating through the characters of the string and assigning them to an element in a cstring.
Mar 12 '07 #6

P: 39
this function will only work copying to a char*, NOT to a string data type
Expand|Select|Wrap|Line Numbers
  1. strcpy(char* destination,const char* source)
  2.  
Mar 12 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.