Re: I cant do change string to int.
- From: Chris Dollin <eh@xxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 11 Nov 2007 16:10:21 GMT
emre esirik(hacettepe computer science and engineering) wrote:
char poli[50];
int p;
scanf("%s", poli);
if(poli[i]=='X' && poli[i+1]=='^')
{
toplam=i+3;
p=poli[i+2];
/Please/ don't offer us random fragments of code; offer us
complete (but small) compilable (unless of course your problem
is a compilation problem) programs. For example, the fragment
above doesn't have a declaration for `i` in it: what /else/
has been missed out?
Are you /sure/ you want to be using `scanf` here, rather than
`fgets`?
p is a ASCII code of integer but I need integer
for example if poli[i+2]='2' it puts p 50 (ascii code of '2')
but I need p=2 integer form, how can I do, please help
To convert a digit character into the corresponding value, you
simply subtract `'0'`, eg
int seven = '7' - '0';
C specifies that the digit characters are in order without gaps
(whereas it does /not/ do this for letters).
--
Non-Digital Hedgehog
"The path to the web becomes deeper and wider" - October Project
.
- Follow-Ups:
- Re: I cant do change string to int.
- From: emre esirik(hacettepe computer science and engineering)
- Re: I cant do change string to int.
- References:
- I cant do change string to int.
- From: emre esirik(hacettepe computer science and engineering)
- I cant do change string to int.
- Prev by Date: Re: dumpbin with debug and release version
- Next by Date: Re: Function pointer dereference security
- Previous by thread: Re: I cant do change string to int.
- Next by thread: Re: I cant do change string to int.
- Index(es):
Relevant Pages
|