Awkward problem with C++'s getline(cin, name) operator...

kompiled

Beta member
Messages
5
I have been working on a simple calender program in C++ and I have come upon a problem with the getline operator. My problem is I want to be able to save a string to a specific point in an array of strings. So I use "getline(cin, tempbuff)" which should take whatever input from "cin >>" and store it in the string tempbuff. However, it's not storing anything in tempbuff after the cin>>. For better review, here is my source code -> www.geocities.com/neo_centre/source.html

If you would take a look at/or compile and run it you'd probably understand what I'm talking about. My problem occurs right before the end of main(). Any reply is appreciated. Oh and btw, you may notice that the libraries I'm using are referenced with '(' rather than '<'. This is because I had to change it cuz HTML wasn't understanding the greater than brackets. It thought they were HTML tags.
 
I don't know too much C++ but here the first parameter of getline is the pointer to take the new string and the second the characters-1 to be extracted.
Also, i think that the size of tmpbuff is only 3....
 
Try this

I reviewed your code and that the char [tempbuff]="Hi", has a size of 2 therefore.. any string larger that this size wont be stored ...

Have u tried using one letter.. or even more... to increase this size ?

Sincerely
CourtneyDS
 
Re: Try this

CourtneyDS said:
I reviewed your code and that the char [tempbuff]="Hi", has a size of 2 therefore.. any string larger that this size wont be stored ...

Have u tried using one letter.. or even more... to increase this size ?

Sincerely
CourtneyDS
Good to see you back courtney.
 
OK, try this

cin.getline(ur_array,length,'\n');
//int i= is used to store the string input to the certain point of array
//length=length of string input
//'\n'=any delimiter
 
Back
Top Bottom