Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #define MAX 128
- typedef struct hoge{
- char name[MAX];
- char mail[MAX];
- }Hoge;
- int main(){
- Hoge * hoge, *init;
- int i;
- hoge = (Hoge *)malloc(sizeof(Hoge) * 3);
- init = hoge;
- strcpy(hoge->name, "aaa");
- strcpy(hoge->mail, "aaa@a.com");
- hoge++;
- strcpy(hoge->name, "bbb");
- strcpy(hoge->mail, "bbb@a.com");
- hoge++;
- strcpy(hoge->name, "ccc");
- strcpy(hoge->mail, "ccc@a.com");
- hoge = init;
- for(i = 0; i<3; i++, hoge++)
- printf("name: %s\n", hoge->name);
- return 0;
- }
Add Comment
Please, Sign In to add comment