/* 整理了下你的代码 : ) */ typedef struct { int a; int b; }frm_struct; frm_struct *my_struct; my_struct = new frm_struct; my_struct-> a=1; my_struct-> b=1; printf("\n%d\n%d\n",my_struct-> a,my_struct-> b); delete my_struct;
typedef struct { int a; int b; }frm_struct; int _tmain(int argc, _TCHAR* argv[]) { frm_struct *my_struct; my_struct = new frm_struct; my_struct-> a=1; my_struct-> b=1; printf("\n%d\n%d\n",my_struct-> a,my_struct-> b); delete my_struct; return 0; }
/* 整理了下你的代码 : ) 我再加上Main函数 */ typedef struct { int a; int b; }frm_struct; int main() { frm_struct *my_struct; my_struct = new frm_struct; my_struct-> a=1; my_struct-> b=1; printf("\n%d\n%d\n",my_struct-> a,my_struct-> b); delete my_struct; }
#include "stdio.h" #include "stdlib.h" typedef struct { int a; int b; } frm_struct; int main(){ frm_struct *my_struct = (frm_struct *)malloc(sizeof(frm_struct)); my_struct-> a=1; my_struct-> b=1; printf("\n%d\n%d\n",my_struct-> a,my_struct-> b); free(my_struct); return 0; }