Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int onlyNumbers(char* text , char* text1, int* text2, int* number)
- {
- char i = 0;
- int k = 0; int run = 0;
- while (text[run++])
- {
- if (text[i]>='0'&&text[i]<='9')
- {
- *(text1+k) = *(text+i);
- k++;
- i++;
- }
- else { i++; }
- }
- text1[k] ='\0';
- for (int j = 0; j < strlen(text1); j++)
- {
- *text2 = (int)text1[j] - (int)'0';
- number = 0;
- number = number * 10 + text2;
- }
- cout << number << ' ' << "*text2"<<"::";
- return *number;
- }
- int main()
- {
- char* text =new char[50];
- char* text1 =new char[50];
- int * text2 =new int[50];
- int* number = 0; cout << "Enter text::";
- cin.getline(text,50);
- onlyNumbers( text, text1,text2,number);
- cout << endl;
- cout << number << "::number2 "<< "*text2"<<'\n';
- system("pause");
- return 0;
- }
- ====
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement