-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path+1arr.c
More file actions
27 lines (24 loc) · 667 Bytes
/
+1arr.c
File metadata and controls
27 lines (24 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdlib.h>
// Returned array must be freeable.
//
// *count is an in/out parameter. It contains the size of arr on input,
// and should be set to the lenght of returned array upon return.
//
// When input is invalid, the function should return NULL and set *count to 0.
int *up_array(const int *arr, unsigned *count)
{
int r = 0; int p[*count];
for (int i = 0; i < *count; i++){
printf("%d", arr[i]);
if (arr[i] < 0 || arr[i] > 9){return NULL;}
r = r *10 + arr[i];
}
r = r + 1;
printf("\n %d", r);
int w = *count;
for (int x = 0; x < *count; x++){
p[x] = r % 10;
r /= 10;
}
return p;
}