From: Maxximo Newsgroups: comp.os.msdos.djgpp Subject: Re: HOW I CAN CONVERT STRING TO INT Date: Mon, 10 May 1999 08:32:28 GMT Organization: Deja.com - Share what you know. Learn what you don't. Lines: 52 Message-ID: <7h65it$mle$1@nnrp1.deja.com> References: <37367C16 DOT 4136 AT hotmail DOT com DOT br> NNTP-Posting-Host: 138.132.53.11 X-Article-Creation-Date: Mon May 10 08:32:28 1999 GMT X-Http-User-Agent: Mozilla/3.04Gold (X11; I; OSF1 V4.0 alpha) X-Http-Proxy: 1.0 s2.deja.com:80 (Squid/1.1.22) for client 138.132.53.11 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In article <37367C16 DOT 4136 AT hotmail DOT com DOT br>, "A.L.A. Corp. / A.S.A. Inc." wrote: > I need this information.. > > I'd like convert strings to interager!! > > example > > main() > { > char comand[50]; > > enter_char(); /// function to get keys of keyboard > > comando="anything 1234" > > check_sintaxe(); // function to separete strings > > comando_1="anything" > comando_2="1234" > > Is.. here! how convert comando_2 as string to interager int..?? > > } > > please.. help me for a workhome of my university..!! > Simply use function atoi(). int i; i = atoi(comando_2); If comando_2 is an alpha string (like "hello, world") atoi() return 0. You must test the value of comando_2 with a loop like this: for(i=0; i < strlen(comando_2); i++) { if(! isdigit(comando_2[i]) ) { printf("wrong value!!\n"); exit(bad); } } Bye Maxximo --== Sent via Deja.com http://www.deja.com/ ==-- ---Share what you know. Learn what you don't.---