Skip to content

Instantly share code, notes, and snippets.

@hirosof
Created June 12, 2012 14:23
Show Gist options
  • Select an option

  • Save hirosof/2917846 to your computer and use it in GitHub Desktop.

Select an option

Save hirosof/2917846 to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <malloc.h>
#include <memory.h>
#define TEXTNUMS 50 //ここは文字列数
#define TEXTSIZE 12 //ここは文字列のサイズ
#define repeat(x) for(int cnt=0 ; cnt < (x) ; cnt++)
int main(void){
char **lplpdata;
//メモリ確保
lplpdata = (char**)malloc(sizeof(char*)*TEXTNUMS);
memset(lplpdata,0,sizeof(char)*TEXTNUMS);
repeat(TEXTNUMS){
*(lplpdata + cnt) = (char*)malloc(sizeof(char)*TEXTSIZE);
memset(*(lplpdata + cnt) , 0 , sizeof(char)*TEXTSIZE);
}
/* ここから処理内容を書く */
printf("「ポインタ一覧」\nlplpdata = 0x%x\n" , lplpdata);
repeat(TEXTNUMS)printf("\t*(lplpdata + %d) = 0x%x\n",cnt,*(lplpdata + cnt));
/* ここまで処理内容を書く */
//メモリ解放
repeat(TEXTNUMS)free(*(lplpdata + cnt));
free(lplpdata);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment