Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy char array into integer array

Status
Not open for further replies.

arul77

Technical User
May 24, 2001
6
IN
Is there any way to copy an char array into integer array
without using a loop structure..
 
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.

Regards,
SwapSawe.
 
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.

Tx for Ur efforts
Arul
 
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.


'1' '2' '1' '0' '0' '\0'

will be converted to 12100

Regards,

Charles
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top