is there a magic function that can combine two or more chars into a single char?
Printable View
is there a magic function that can combine two or more chars into a single char?
you mean like this?
char result:
char first = 'A';
char second = ' ';
result = first + second;
cout << result;
No function I know of, but shouldn't be too hard to do it yourself. Just need to wrap around value if using ASCII char set and sum of ASCII values for first and second is > 255.
Code:char one = "a", two = "b";
int three;
three = (int)a + (int)b;
cout<<(char)three;
//ASCII code stuff to bright for you to see
erion : he wants to add the scii, my post would be correct ^_^
Ehh? He said that he wanted to combine two chars into one.
combine two or more chars into a single char?
combine two or more chars into a single char?
combine two or more chars into a single char?combine two or more chars into a single char?combine two or more chars into a single char?
combine two or more chars into a single char?combine two or more chars into a single char?combine two or more chars into a single char?
combine two or more chars into a single char?vcombine two or more chars into a single char?
vcombine two or more chars into a single char?
vcombine two or more chars into a single char?combine two or more chars into a single char?combine two or more chars into a single char?combine two or more chars into a single char?combine two or more chars into a single char?combine two or more chars into a single char?combine two or more chars into a single char?combine two or more chars into a single char?combine two or more chars into a single char?
starting to get the picture?
he said CHAR not STRING.
as in A + B.
:rolleyes: :rolleyes: I didnt say anything:rolleyes: :rolleyes:
Here's one way:
Or:Code:char message[80];
strcpy(message,"Hello");
strcat(message," world");
cout << message << endl;
Or with string types I think you can:Code:char message[80];
char word[10];
strcpy(message,"Hello");
strcpy(word," world");
strcat(message,word);
cout << message << endl;
Code:string message = "Hello" + " world";
swoopy : read what i told erion, read his post. he didnt ask to combine STRINGS he asked to combine CHARACTERS. as in ascii...
I kind of interpreted what he said, to what he really meant. I could be wrong.
if you combine characters you make a string don't ya? :)
so make a char array of say 100 elements.. copy each char into the first two segments of your array then add the \0 to position three.. you now have a string, but u did add your two chars together!
or just scan em in as strings and strcat!
TWO CHARACTERS INTO ONE. INTO ONE CHARACTER U STUPID MOFO.
HOW ARE YOU PEOPLE SO STUPID? PUTTING 2 TOGeTHER MEANS TO CHARACTERS. ONE CHARACTER IS NOT ADDING STRINGS *craps pants*
I don't think heat511 knows what he wants. He probably wants to take two characters and turn them into a string, but nobody really knows b/c he doesn't understand the terminology.
So everybody just chill out
You are an idiot, denethor. Note the use of 'combine.' When you combine two items, you do not just add them together. As biosx said, heat's grasp of the terminology involved is not sufficient to be able to express himself clearly. BTW, is there something in the sentence "Please don't clutter the post up with CAPS." (from the FAQ) that you are incapable of understanding?Quote:
is there a magic function that can combine two or more chars into a single char?
young children tend to do thatQuote:
*craps pants*