LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-12-2006, 07:32 AM   #1
killer_instinct
LQ Newbie
 
Registered: Dec 2006
Posts: 26

Rep: Reputation: 15
converting char * to int


hi
did any one know how to convert a char to an int?
 
Old 12-12-2006, 07:38 AM   #2
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
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.

Last edited by vharishankar; 12-12-2006 at 07:39 AM.
 
Old 12-12-2006, 07:48 AM   #3
killer_instinct
LQ Newbie
 
Registered: Dec 2006
Posts: 26

Original Poster
Rep: Reputation: 15
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!!!!!
 
Old 12-12-2006, 07:52 AM   #4
Broder
Member
 
Registered: Oct 2006
Location: Santa Barbara, C.A.
Distribution: Mood dependent
Posts: 117

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

Last edited by Broder; 03-13-2007 at 12:23 PM.
 
Old 12-12-2006, 07:54 AM   #5
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
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';
 
Old 12-12-2006, 07:58 AM   #6
killer_instinct
LQ Newbie
 
Registered: Dec 2006
Posts: 26

Original Poster
Rep: Reputation: 15
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?
 
Old 12-12-2006, 08:31 AM   #7
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
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...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting int to char* in C hakmed Programming 6 11-01-2006 07:17 PM
char to int: a twist Guru3 Programming 5 12-05-2004 08:49 AM
Converting int value to char liguorir Programming 8 05-23-2004 07:21 PM
int(char(254)) becomes kalleanka Programming 2 02-17-2004 03:35 PM
switch statement converting struct char to struct int oceaneyes2 Programming 2 12-10-2003 04:30 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration