I am making a
I know that \n means an enter. But what is the "code" thing for a space?Code:cin.getline(word_1, 50, 'I_want_a_space_here')
Update: Ok now I am guessing I am looking like an idoit, and just puting a space shoudl work right?
I am making a
I know that \n means an enter. But what is the "code" thing for a space?Code:cin.getline(word_1, 50, 'I_want_a_space_here')
Update: Ok now I am guessing I am looking like an idoit, and just puting a space shoudl work right?
Last edited by Rune Hunter; 09-15-2004 at 04:48 PM.
First of all, they are called "escape sequences", not "code" thing, lol. The \n means newline. As for an escape sequence for a single space, I can't recall there being one, if I am wrong, I am sure someone will correct me on this. If you want to do a tab, you can use \t.
Look up the escape sequences in your help files or try doing a google search on C++ escape sequences. I did just to make sure I was right about there not being one for single spaces and it looks like I am most likely correct, but take a look for yourself.
well I am prettys rue there is one sence just a ' ' doesn't work. I have to hit enter if I put that in there.
hmmm...well if i had my laptop i could take a look, but it is at work so i am a little stuck here.
oh wait...instead of using ' around your string, try " instead.
didn't work.
Space is 0x20 ( hex ) as far as its ascii value is concerned.
What is C++?
Well, I am sorry I couldn't be of help, without my laptop, I am powerless.
The space ' ' works fine. You expect it to stop letting you type after the space, but that is not how standard input works. It will let you type until you hit Enter, then it will only read the first word up until a space into word_1. This program outputs only the first word if you type in several words separated by a space.Code:#include <iostream> int main() { char word_1[50]; std::cin.getline(word_1, 50, ' '); std::cout << word_1 << std::endl; }
std::cin.getline ( word_1, 50, 0x20);
Will take all input until enter is pressed... but only put whatever is before the first space into word_1.
using \t you can keep typing until you hit tab.
[edit]
std::cin.getline ( word_1, 50, '\x20');
If you want to use an escape sequence.
Last edited by Vicious; 09-15-2004 at 05:20 PM.
What is C++?
alright thanks.