Created
June 12, 2012 14:23
-
-
Save hirosof/2917846 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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