形參、實參、返回值

// hellopoint.cpp : 定義控制檯應用程序的入口點。
//

#include "stdafx.h"
#include <stdio.h>
#include <malloc.h>
#include <string.h>
char* GetMem(int nsize);
void GetChar(char*p );
int _tmain(int argc, _TCHAR* argv[])
{
    char* temp=NULL;
    temp=GetMem(18);

 
    printf("\ntemp add  %x  內容以下%s",&temp,temp);

    char *temp2=NULL;
    GetChar(temp2);
    printf("\n%s",temp2);
    printf("\ntemp2 add  %x  內容爲 %s",&temp2,temp2);

    while (true)
    {
    }
    return 0;
}

char* GetMem(int nsize)
{
    char* p=NULL;
    p=(char*)malloc(sizeof(char)*nsize);
    
    strcpy(p,"here is ok");;
    printf("\np  add %x context is %s",&p,p);
    return p;
}


void GetChar(char*p )
{
    p=(char*)malloc(sizeof(char)*18);
    strcpy(p,"here is 2222");
    printf("\n GetChar p2 add %x  context is %s",&p,p);
}



相關文章
相關標籤/搜索