| | |
Converting a String into an integer array
![]() |
Don't know is it the best way but you can do like this. Parse the string until the space (' ') and the number until the space convert to int element of array.
If you want to win, you must not loose (Alan Ford)
•
•
Join Date: Sep 2006
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
Don't know is it the best way but you can do like this. Parse the string until the space (' ') and the number until the space convert to int element of array.
I thought something like below would do the trick but i keep getting cast errors.
while (*string != '\0')
{
for (i = 0; i < strlen(string); i++)
{
converted[i] = atoi((int)string[i]);
}
}
Correct me if I'm wrong...but doesn't atoi() require a C-String as the argument?
C Syntax (Toggle Plain Text)
char input[20]; code...code...code... atoi(input);
Last edited by FC Jamison; Sep 20th, 2006 at 11:11 am.
•
•
•
•
Hi,
I have a question which i have no idea how to do manage.
I need to convert a string in the format like "1 234 567" so i can do some calculations on the indvidual numbers.
What is the best way to do this?
Thanks
Last edited by Bench; Sep 20th, 2006 at 11:17 am.
¿umop apisdn upside down? I think you should avoid casts as much as possible unless there's no option left or it turns out to be less evil then the other option.
The key to eliminating bugs from your code is learning from your mistakes.
![]() |
Similar Threads
- emu8086 and arrays (Assembly)
- Coverting a string to a byte array (Visual Basic 4 / 5 / 6)
- Converting String to Integer help (C++)
- Conver int Array into a String (Java)
- string to integer array transformation (C)
Other Threads in the C Forum
- Previous Thread: using strtok() to populate and array
- Next Thread: converting int to char in C
| Thread Tools | Search this Thread |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile createprocess() csyntax database directory dynamic feet fflush fgets file fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o include incrementoperators input interest kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix meter microsoft motherboard mqqueue mysql number odf open openwebfoundation owf pattern pdf performance pointer posix probleminc process program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling segmentationfault send sequential shape socket socketprograming stack standard string systemcall turboc unix user voidmain() wab win32api windows.h





