A characteristic number two pointers

#if 1
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <math.h>
void allocateSpace(int** p) {
    int* temp = malloc(sizeof(int) * 10);
    for (int i = 0; i < 10; i++) {
        temp[i] = 100 + i;
    }
    *p = temp;
}
void printArray(int** arr, int len) {
    for (int i = 0; i < len; i++) {
        printf("%d\n",(arr)[i]);
    }
}

void freeArray(int* arr) {
    if (arr != NULL) {
        free(*arr);
        *arr = NULL;
    }
}
test01() {
    int* p =NULL; 
    allocateSpace ( & P);
     // print array 
    printArray (& P, 10 );
     // release array 
    freeArray (& P);
     IF (P == NULL) { 
        the printf ( " null pointer \ n- " ); 
    } 
    the else { 
        the printf ( " wild pointer \ n- " ); 
    } 
} 

int main ( int argc, char * the argv []) 
{ 
    Test01 (); 
    System ( " PAUSE " );
    return 0;
}
#endif

19:59

Guess you like

Origin www.cnblogs.com/MyLoveLiJuan/p/11852361.html