[SDL] Help ME!!!!!!!!!
Dido Sevilla
dido at pacific.net.ph
Wed Jun 14 20:28:35 PDT 2000
Otavio Pliger wrote:
>
> Hello!!!
>
> I have 2 problems, one In Topic and another Off Topic.
> ---------------------
> InTopic Prolem
> ---------------------
> SDL can't find my cdrom drive on BeOS!!!!!!
>
Since I don't use BeOS, I can't help with this.
>
> ------------------------
> OffTopic Problem
> ------------------------
> I want to create a function that take all numbers of a string.
> for example:
>
> char *string = "abc24";
>
> GetNumbers(string);
>
> returns me 24.
>
Try doing something like this:
int GetNumbers(char *string)
{
char numberstr[80];
int i, j;
j=0;
numberstr[0] = 0; /* so
for (i=0; i<strlen(string); i++) {
if (isdigit(string[i]))
numberstr[j++] = string[i];
}
return(atoi(numberstr));
}
If you want a *string* of the numbers, return strdup(numberstr) instead
of atoi(numberstr).
--
Rafael R. Sevilla <dido at pacific.net.ph> +63 (2) 4342217
Mobile Robotics Laboratory +63 (917) 4458925
University of the Philippines Diliman
More information about the SDL
mailing list