From: "Al Morgan" Newsgroups: comp.os.msdos.djgpp Subject: Re: HOW I CAN CONVERT STRING TO INT Date: Sat, 15 May 1999 22:07:14 -0700 Organization: Posted via RemarQ Communities, Inc. Lines: 27 Message-ID: <926831536.730.86@news.remarQ.com> References: <37367C16 DOT 4136 AT hotmail DOT com DOT br> <7hie07$a6v$1 AT newssrv DOT otenet DOT gr> NNTP-Posting-Host: 198.106.195.132 NNTP-Posting-Date: Sun, 16 May 1999 05:12:16 GMT X-Trace: 926831536.730.86 4VELK9AUPC384C66AC qube-01.us-ca.remarq.com X-Complaints-To: newsabuse AT remarQ DOT com X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Not sure about a function that comes with the C compiler, but I usually just write my own: int string2int(char *s) { int place = 1; // the current place it is reading (i.e. 1's 10's 100's) int r = 0; // the final product (or where it WILL be) for(n = strlen(s); n >=0; --n, place *= 10) // start at the right and count to the left r += (*(s + n) - 48) * place; // 48 is the ASCII value for '0', so to convert from a single char // to it's integer value, you would simply subtract 48 return r; } There you have it (in case you are wondering, all my indents are screwed up beacuse I'm trying to type this in a, what's the word??, non-monospaced font.) Hope this helps, Al Morgan [muaddib AT proaxis DOT com]