.:: Need a Help in C

badtnc

Member
Jul 17, 2007
3,980
51
0
Nugegoda, Anuradhapura
I need a big help 4m u guys

i need to convert string array to a int.


Code:
char arr1[20];
int array[20];

printf("enter the values");
gets(arr1);  //sample inputs are 20^11^8^9

so i need to saparate des int values and store them in int array. so i can make de calculation..
can some one help me..
 

x-pert

Member
Jun 13, 2006
20,952
77
0
Ranhiru said:
I saw fazaal asking for the same thing... check threads started by Fazaal....
and to once you get the number separated by ^ use a function named atoi...

http://en.wikipedia.org/wiki/Atoi

Ya I think atoi function would help.
If not check strtol function.

Either way, you might need to use a if loop to separate the numbers
(e.g. if char i = '^', separate the string from the position.)
This if loop has to be inside a for or a while loop in order to scan through the whole string.

Just a quick idea :)

Check and see machan.
 

badtnc

Member
Jul 17, 2007
3,980
51
0
Nugegoda, Anuradhapura
x-pert said:
Ya I think atoi function would help.
If not check strtol function.

Either way, you might need to use a if loop to separate the numbers
(e.g. if char i = '^', separate the string from the position.)
This if loop has to be inside a for or a while loop in order to scan through the whole string.

Just a quick idea :)

Check and see machan.

tx machan..
it worked!!!!!!