zoukankan      html  css  js  c++  java
  • 《深入理解C指针》第三章 指针和函数

    2019-12-01

    16:42:32

     

     

     

     

     

     

     

     

     

     

    #include <bits/stdc++.h>
    #include <stdlib.h>
    #include <stdio.h>
    using namespace std;
    #define maxn 10005
    #define M 105
    void allocateArray(int **arr,int size,int value){
        *arr = (int*)malloc(size * sizeof(int));
        printf("%p
    ",arr);
        if(*arr != NULL){
            for(int i=0;i<size;++i){
                *(*arr+i) = value;
            }
        }
    }
    int main(){
        int *vector = NULL;
        allocateArray(&vector,5,45);
        printf("%p
    ",vector);
        for(int i=0;i<5;++i){
            printf("%d
    ",vector[i]);
        }
        system("pause");
        return 0;
    } 

     

     

     

     

     

     

     

     

    #include <bits/stdc++.h>
    #include <stdlib.h>
    #include <stdio.h>
    using namespace std;
    #define maxn 10005
    #define M 105
    int (*fptrl)(int);
    int square(int num){
        return num*num; 
    }
    int main(){
        int n = 5;
        fptrl = square;
        printf("%d squared is %d
    ",n,fptrl(n));
        system("pause");
        return 0;
    } 

     

     

  • 相关阅读:
    轻时代来临 资深架构师分享手游五大设计要点
    Netty 介绍
    Socket编程与线程
    java多线程并发访问解决方案
    throws 和throw 的区别
    JRE
    Servlet的生命周期
    页面介绍
    项目技术介绍
    软件开发环境
  • 原文地址:https://www.cnblogs.com/JasonPeng1/p/11966522.html
Copyright © 2011-2022 走看看