Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #define lengthMAX 1000
- int foo(char*,char*,int*);
- int main() {
- int size = 0;
- char* string = (char*)malloc(lengthMAX * sizeof(char));
- gets_s(string, lengthMAX);
- char* new_string = (char*)malloc(lengthMAX * sizeof(char));
- int* new_array = (int*)malloc(lengthMAX * sizeof(int));
- size = foo(string, new_string, new_array);
- puts(new_string);
- for (int i = 0; i < size; ++i) {
- printf("%d ", new_array[i]);
- }
- system("pause");
- }
- int foo(char* string,char* new_string,int* new_array) {
- int size_of_array = 0;
- for (int i = 0; i < lengthMAX; ++i) {
- if (string[i] <= '9' && string[i] >= '0') {
- *new_array = (int)(string[i] - '0');
- ++new_array;
- ++size_of_array;
- }
- else {
- *new_string = string[i];
- ++new_string;
- }
- }
- *new_string = '/0';
- return size_of_array;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement