Article View: att.lang.c++
Article #67Fast Question about Conversion
From: 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" ;
}
Technical Details
Message-ID:
<01bf78e4$2e6dfd20$d6811a3f@default>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4ba,8cb43d01ff91840d,start X-Google-Attributes: gid10d4ba,public From: "Nathan" <nathanael_n@hotmail.com> Subject: Fast Question about Conversion Date: 2000/02/17 Message-ID: <01bf78e4$2e6dfd20$d6811a3f@default> X-Deja-AN: 586745330 Distribution: world X-Abuse-Info: Otherwise we will be unable to process your complaint properly X-Complaints-To: abuse@gte.net X-Trace: /bGnt5aRBF+VO1xhkBv0YFwDgOsD56eoltemuxOq1+hm9StWUNo5qT35onuFnGrPXBOM/oUZrCi7!E6SIqV4kr4DM8ReWjsn7rHqBK/+NgaYptUjzAWAxzWQMGneafT+GpcDYHsklCo46MAs0 NNTP-Posting-Date: Thu, 17 Feb 2000 01:16:19 GMT Newsgroups: att.lang.c++