| | |
Converting a String into an integer array
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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
Views: 6767 | Replies: 11
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays asterisks binarysearch calculate centimeter char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory dynamic executable fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix problem probleminc program programming radix recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming spoonfeeding stack standard string strings structures student systemcall testautomation turboc unix user variable visualstudio voidmain() wab win32 windows.h





