You need to meet Mr. OK and Mr. Num. But first, welcome to the forum, DanielB33!
Unless you know the function exists, it's difficult to put together an algorithm.
The header file ctype.h, has functions that will give tests for different types of data. This is an example of using one named isdigit().
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int main(void) {
int i,j,num,len;
char data[20]={"abc10def20ghi999"};
len=strlen(data);
char *ok=malloc(len);
if(!ok) {
printf("memory allocation failed!\n");
return 1;
}
for(i=0,j=0;i<len;i++) { //scan the array
if(isdigit(data[i])) { //if the char is a digit
ok[j]=data[i]; //copy it over to ok[]
++j; //to the next free index location
}
}
printf("%s\n",ok); //number as a string
num=atoi(ok); //convert it to an int
printf("%d\n",num); //and show it
free(ok); //free the malloc'd array memory
return 0;
}
This is a freebie, but follow the advice given by Matticus above:
Always surround any code you post with code tags
Post an attempt to solve the problem. Otherwise, the forum tends to become a "do my homework for me" site, for hordes of students.