转载  一道普通的面试一题目指针做参数 收藏

主要要求么就考指针的针作参数,啊忘记写assert了,汗这次又危险了哪!T_T

  1. 主要要求么就考指针的针作参数,啊忘记写assert了,汗这次又危险了哪!T_T
  2. #include <stdio.h>
  3. #include <iostream.h>
  4. #include <string.h>
  5. #include <conio.h>
  6. #include <stdlib.h>
  7. char * fun1( char** p);
  8. void main()
  9. {
  10.        clrscr();
  11.        char* p =NULL ;
  12.        fun1(&p);
  13.        printf("%s\n", p);
  14.        puts(p);
  15.        free(p);
  16.  
  17. }
  18.  
  19. char*  fun1(char** p)
  20. {
  21.        char *p1;
  22.        *p =(char*)malloc(sizeof(char)*12);
  23.        p1 = *p;
  24.        for(char i ='a'; i<('a'+11); i++)
  25.        {
  26.               *p1++ = i;
  27.        }
  28.        *p1 = '\0';
  29.  
  30.        return  *p;
  31.  
  32. }

发表于 @ 2008年09月19日 11:24:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:epoll 学习 | 新一篇:C++中Static作用和使用方法

  • 发表评论
  • 评论内容:
  •  
Copyright © zhengjie19
Powered by CSDN Blog