LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   converting char * to int (https://www.linuxquestions.org/questions/programming-9/converting-char-%2A-to-int-509694/)

killer_instinct 12-12-2006 07:32 AM

converting char * to int
 
hi
did any one know how to convert a char to an int?

vharishankar 12-12-2006 07:38 AM

I'm guessing you want to convert a string representation of a number into its equivalent form in which case atoi () is the recognized function to convert a character representation of a number into its integer equivalent.

killer_instinct 12-12-2006 07:48 AM

the problem that i use unix suse
i have many freinds that said to me atoi will not work on unix(i mean language c under unix )
did you test that with unix suse.
i will try it when get back to home but here in my school they said it does not work!!!!!

Broder 12-12-2006 07:52 AM

The C language was developed specifically for use with unix. You will need to install gcc compiler if you don't already have it.

taylor_venable 12-12-2006 07:54 AM

Yeah, it'll work under Unix. Try `man atoi` at your shell. Also, your title said to convert a char* to an int, which is what atoi() does. But your post said to convert a char, which is different. To convert a single char like '7', do this: int x = (int)ch - (int)'0';

killer_instinct 12-12-2006 07:58 AM

that's it man
thank you Mr taylor venable
thank you very much
this is what i'm looking for
int x=(int)ch; where ch is a char
again thank you very much

please can i ask here question about GTK or QT?

bulliver 12-12-2006 08:31 AM

Quote:

please can i ask here question about GTK or QT?
Of course. Though, you will want to start a new thread with an appropriate subject line...


All times are GMT -5. The time now is 11:55 PM.