473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

declaring cin.getline() vs getline()

12
what is the difference between the cin.getline() function and getline() function?
Mar 12 '07 #1
6 3544
sicarie
4,677 Expert Mod 4TB
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
5,000 Expert 4TB
Nothing except one version you explicitly call it on the cin stream whereas the other is implicit.
Mar 12 '07 #3
yana
12
Can you initialize C++ string from C-string? and
Can you initialize C-string from C++ string?
Mar 12 '07 #4
sicarie
4,677 Expert Mod 4TB
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
3,652 Expert 2GB
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
lqdeffx
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

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

Similar topics

2
by: Vikram | last post by:
Hi, I don't remember if it happened previously, but nowadays I'm having problem with using cin.getline function and cin>> function simultaneously. I have Visual Studio 6. If I use cin.getline...
5
by: vknid | last post by:
Hello, I have a question. Its probably a very newbish question so please be nice hehe. =D I have been reading through C++ Programming Fundamentals, and have come a crossed an example program...
1
by: ma740988 | last post by:
Consider: ifstrem MyFile("extractMe.txt"); string Str; getline(MyFile, Str); getline above extracts the contents of MyFile and place into the string object. Deduced using FROM/TO logic I...
10
by: Skywise | last post by:
I keep getting the following error upon compiling: c:\c++ files\programs\stellardebug\unitcode.h(677) : error C2664: 'class istream &__thiscall istream::getline(char *,int,char)' : cannot convert...
14
by: KL | last post by:
I am so lost. I am in a college course for C++, and first off let me state I am not asking for anyone to do my assignment, just clarification on what I seem to not be able to comprehend. I have a...
18
by: Amadeus W. M. | last post by:
I'm trying to read a whole file as a single string, using the getline() function, as in the example below. I can't tell what I'm doing wrong. Tried g++ 3.2, 3.4 and 4.0. Thanks! #include...
2
by: jalkadir | last post by:
I am trying to get character string from the user, to do that I use getline(char_type*, streamsize), but I get a segmentation fault??!! Can anyone give me a hand, what am I doing wrong? --snip...
4
by: snow.carriers | last post by:
http://www.rafb.net/paste/results/fTQgRW16.html Here's my program so far. This is what I'm trying to do: http://contest-cemc.uwaterloo.ca/ccc/2005/senior/phone.pdf So far it works fine. The only...
33
by: Chen shuSheng | last post by:
I have a code: --------------------------- #include <iostream.h> #include <stdlib.h> int main() { int max=15; char line; getline(line,max); system("PAUSE");
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.