LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C++ string object; add whitespace controll character (https://www.linuxquestions.org/questions/programming-9/c-string-object%3B-add-whitespace-controll-character-696912/)

sureshkellemane 01-13-2009 12:51 AM

C++ string object; add whitespace controll character
 
Friends,

I am trying to add white space into C++ string, but I have no clue.

Is that possible?

Please help me.

Thanks
Suresh

chakka.lokesh 01-13-2009 12:52 AM

try with gets() function. and take care about string over flow.

sureshkellemane 01-13-2009 02:35 AM

Thanks for response .. can you please elabaorate...
I want to add character by character into C++ string.

Is there any way I can specify it saying I am adding controll character?

Thanks
Suresh

chakka.lokesh 01-13-2009 03:09 AM

you can use any of getchar(), getche() getch().

ntubski 01-13-2009 04:52 PM

Maybe you mean something like
Code:

the_string += ' '; // adding a space
the_string += '\n'; // adding a new-line
the_string += '\t'; // adding a tab


ta0kira 01-13-2009 06:31 PM

Or:
Code:

std::string my_string = "testdata";
my_string.insert(my_string.begin() + 4,' ');
my_string.insert(4," ");

ta0kira


All times are GMT -5. The time now is 04:22 AM.