Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(int argc, char const *argv[]){
- int *array ;
- foo(array) ;
- /* Rest of the code */
- }
- int foo(int *array){
- // I know I am missing some *malloc not working* if's
- int *temp , j = 0 , i;
- array = malloc(sizeof(int)) ;
- if (array){
- for (i=0 ; i < 10 ; i++){
- array[j] = i*i ;
- temp = realloc( array , (++j+1)*sizeof(int) ) ;
- if (temp != NULL ) {
- array = temp ;
- }
- }
- }
- return j
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement