Thread View: att.lang.c++
1 messages
1 total messages
Started by Nathan
Thu, 17 Feb 2000 00:00
Fast Question about Conversion
Author: Nathan
Date: Thu, 17 Feb 2000 00:00
Date: Thu, 17 Feb 2000 00:00
34 lines
1533 bytes
1533 bytes
Hi,
I am trying to convert an int to a char.
Well, not really:
I want to convert the int 100 to the char string "100". (This would be
easier in Perl, I think.)
If I just recast the int into a char, I get the letter 'd'. Not what I
wanted at all.
It does not work at all to try to convert the int to a char* or char[].
I need to use a int for a function that wants a char. So I need to know how
to do this.
I left some code below to help visualize the problem.
,Thanks for any help given.
,Nathan
nathanael_n@hotmail.com
#include <iostream.h>
main() {
int intTemp = 100 ;
char charTemp = intTemp ;
/* This will only produce the letter 'd' and not the char string "100" */
cout << "This is the int value: " << intTemp<< "\n" ;
cout << "This is the int value converted to a char format: " << charTemp
<< "\n" ;
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads