Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int* onlyNumbers(char* text)
- {
- char* temp_ptr = text;
- int count = 0;
- while(*temp_ptr)
- {
- if(isdigit(*temp_ptr))
- {
- while(isdigit(* ++temp_ptr)){}
- ++count;
- }
- if (*temp_ptr)
- ++temp_ptr;
- }
- int *result = new int[count + 1];
- result[0]= count;
- temp_ptr = text;
- int index = 1;
- while (index <= count)
- {
- if (isdigit(*temp_ptr))
- {//hjgf45365sdg
- result[index++] = strtoll(temp_ptr, &temp_ptr, 10);
- }
- ++temp_ptr;
- }
- return result;
- }
- int main()
- {
- char* text = new char[255];
- cout << "Enter text: ";
- cin.getline(text, 50);
- int *res = onlyNumbers(text);
- for (int i = 1; i <= *res; ++i)
- {
- cout << res[i]*10 << " ";
- }
- cout << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement