Re: Question in C



  To the original author.

   Do you have a char or a <em> pointer </em> to a char ?

   1) if you have a char

       int i = (int) my_char;

   2) if you have a pointer to a char:  i.e  char* c = "34";

       int i = atoi(my_char);

 
 I think the wording is confusing a lot of people.

Harring



       
 
--- "John (J5) Palmieri" <johnp martianrock com> wrote:
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
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools



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