i think your problem can be resolved by using function "atoi" you must check for help by pressing ctrl+F1 under atoi and you will get it. congrats if it severes your purpose. vsood2@yahoo.com
Your question is very typical. May I know how u think u can traverse through the array if u are headbound not to use loop. Ya ther is another way and it is recusrion functions. But Pls clarify what and where exactly the problem arises if use loops which will be relatively simpler. And for conversion u'll have to use atoi as soodvarun said.
hi
I am a new child for c programming, the need arised when
i tried to read a file using fgets into an chararray.
I need to transfer the value in the char array [which i know is a numeric value] into an int variable, since i need to convert that value read from file into ASCII, using "toascii" which only accepts int as argument.I know there will be many ways to do this,i just wanted to find whether there is a way to solve this as i tried.
If you want to make the array into an int variable, why are you trying to convert it into an int array? If you pass the pointer to your char array to atoi or atol, it will convert the whole array into its integer/long value. E.g.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.