Re: Question in C



On Fri, 2004-02-20 at 13:02, John Coppens wrote:
On Fri, 20 Feb 2004 17:27:18 -0000
"Thomas Keaney" <se40319 cs may ie> wrote:

Hi,
How would I change a char to an int. I have the value "34" as a
character. I want to change this to an int (34). Cheers

char is in fact an (smaller) int. So you can just assign the char value to
an int - no problem.

Uh, don't do that.  First 

char a[] = "34";
int b = a;

would give you the address of the pointer a.  Second.

char a[] = "34"; 
int b = a[0]; 

would give you the ascii character code for '3' 

--
J5



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]