int main() { int (**table)[2] = hnew(); hset(table, 10, 20); hset(table, 20, 30); hset(table, 30, 40); int (**a)[2] = hget(table, 10); int (**b)[2] = hget(table, 20); int (**c)[2] = hget(table, 30); printf("%d:%d\n", (**a)[0], (**a)[1]); printf("%d:%d\n", (**b)[0], (**b)[1]); printf("%d:%d\n", (**c)[0], (**c)[1]); hdel(table); }
int main(int argc, const char **argv) { STR *str; int i; STR *tmpstr; /* char *namelist; */ #ifdef NETWARE fnInitGpfGlobals(); /* For importing the CLIB calls in place of Watcom calls */ #endif /* NETWARE */ myname = argv[0]; linestr = str_new(80); for (argc--,argv++; argc; argc--,argv++) { if (argv[0][0] != '-' || !argv[0][1]) break; switch (argv[0][1]) { #ifdef DEBUGGING case 'D': debug = atoi(argv[0]+2); #if YYDEBUG yydebug = (debug & 1); #endif break; #endif case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': maxfld = atoi(argv[0]+1); absmaxfld = TRUE; break; case 'F': fswitch = argv[0][2]; break; case 'n': namelist = savestr(argv[0]+2); break; case 'o': old_awk = TRUE; break; case '-': argc--,argv++; goto switch_end; case 0: break; default: #if defined(OS2) || defined(WIN32) || defined(NETWARE) fprintf(stderr, "Unrecognized switch: %s\n",argv[0]); usage(); #else fatal("Unrecognized switch: %s\n",argv[0]); #endif } } switch_end: /* open script */ if (argv[0] == NULL) { #if defined(OS2) || defined(WIN32) || defined(NETWARE) if ( isatty(fileno(stdin)) ) usage(); #endif argv[0] = "-"; } filename = savestr(argv[0]); if (strEQ(filename,"-")) argv[0] = ""; if (!*argv[0]) rsfp = stdin; else rsfp = fopen(argv[0],"r"); if (rsfp == NULL) fatal("Awk script \"%s\" doesn't seem to exist.\n",filename); /* init tokener */ bufptr = str_get(linestr); symtab = hnew(); curarghash = hnew(); /* now parse the report spec */ if (yyparse()) fatal("Translation aborted due to syntax errors.\n"); #ifdef DEBUGGING if (debug & 2) { int type, len; for (i=1; i<mop;) { type = ops[i].ival; len = type >> 8; type &= 255; printf("%d\t%d\t%d\t%-10s",i++,type,len,opname[type]); if (type == OSTRING) printf("\t\"%s\"\n",ops[i].cval),i++; else { while (len--) { printf("\t%d",ops[i].ival),i++; } putchar('\n'); } } }