这篇教程C++ strtol函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中strtol函数的典型用法代码示例。如果您正苦于以下问题:C++ strtol函数的具体用法?C++ strtol怎么用?C++ strtol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了strtol函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: pack_fopen/* load_txt_font: * Loads a scripted font. */FONT *load_txt_font(AL_CONST char *filename, RGB *pal, void *param){ char buf[1024], *font_str, *start_str = 0, *end_str = 0; char font_filename[1024]; FONT *f, *f2, *f3, *f4; PACKFILE *pack; int begin, end, glyph_pos=32; pack = pack_fopen(filename, F_READ); if (!pack) return NULL; f = f2 = f3 = f4 = NULL; while(pack_fgets(buf, sizeof(buf)-1, pack)) { font_str = strtok(buf, " /t"); if (font_str) start_str = strtok(0, " /t"); if (start_str) end_str = strtok(0, " /t"); if (!font_str || !start_str) { if (f) destroy_font(f); if (f2) destroy_font(f2); pack_fclose(pack); return NULL; } if(font_str[0] == '-') font_str[0] = '/0'; begin = strtol(start_str, 0, 0); if (end_str) end = strtol(end_str, 0, 0); else end = -1; if(begin <= 0 || (end > 0 && end < begin)) { if (f) destroy_font(f); if (f2) destroy_font(f2); pack_fclose(pack); return NULL; } /* Load the font that needs to be merged with the current font */ if (font_str[0]) { if (f2) destroy_font(f2); if (exists(font_str)) { f2 = load_font(font_str, pal, param); } else if (is_relative_filename(font_str)) { replace_filename(font_filename, filename, font_str, sizeof(font_filename)); f2 = load_font(font_filename, pal, param); } else { f2 = NULL; } if (f2) glyph_pos=get_font_range_begin(f2, -1); } if (!f2) { if (f) destroy_font(f); pack_fclose(pack); return NULL; } if (end == -1) end = begin + get_font_range_end(f2,-1) - glyph_pos; /* transpose the font to the range given in the .txt file */ f4=extract_font_range(f2,glyph_pos,glyph_pos + (end - begin)); if (f4 && (begin != glyph_pos)) { transpose_font(f4, begin - glyph_pos); } glyph_pos += (end - begin) + 1; /* FIXME: More efficient way than to repeatedely merge into a new font? */ if (f && f4) { f3 = f; f = merge_fonts(f4, f3); destroy_font(f4); destroy_font(f3); } else {//.........这里部分代码省略.........
开发者ID:AntonLanghoff,项目名称:whitecatlib,代码行数:101,
示例2: parseSectionint parseSection(char *s, int *x0, int *x1, int *y0, int *y1, int *block){ int itype=0, got=0; double tx0=0, tx1=0, ty0=0, ty1=0; double dim1, dim2, cen1, cen2; char s1[SLEN], s2[SLEN], s3[SLEN], s4[SLEN], s5[SLEN]; char *t; /* look for different ways of specifying the section -- order counts! */ if(sscanf(s, "%32[-0-9.dDeE] : %32[-0-9.dDeE] , %32[-0-9.dDeE] : %32[-0-9.dDeE] , %32[0-9]", s1, s2, s3, s4, s5) == 5){ tx0 = atof(s1); tx1 = atof(s2); ty0 = atof(s3); ty1 = atof(s4); *block = MAX(1, atof(s5)); got = 1; } else if(sscanf(s, "%32[-0-9.dDeE] : %32[-0-9.dDeE] , %32[-0-9.dDeE] : %32[-0-9.dDeE]", s1, s2, s3, s4) == 4){ tx0 = atof(s1); tx1 = atof(s2); ty0 = atof(s3); ty1 = atof(s4); *block = 1; got = 1; } else if(sscanf(s, "%32[-0-9.dDeE] : %32[-0-9.dDeE] , %32[0-9as]", s1, s2, s3) == 3){ tx0 = atof(s1); tx1 = atof(s2); ty0 = tx0; ty1 = tx1; *block = MAX(1, atof(s3)); got = 1; } else if(sscanf(s, "%32[-0-9.dDeE] : %32[-0-9.dDeE]", s1, s2) == 2){ tx0 = atof(s1); tx1 = atof(s2); ty0 = tx0; ty1 = tx1; *block = 1; got = 1; } else if(sscanf(s, "%32[0-9.dDeE] @ %32[-0-9.dDeE] , %32[0-9.dDeE] @ %32[-0-9.dDeE] , %32[0-9]", s1, s2, s3, s4, s5) == 5){ dim1 = atof(s1); cen1 = atof(s2); dim2 = atof(s3); cen2 = atof(s4); *block = MAX(1, strtol(s5, &t, 0)); itype = 1; got = 1; } else if(sscanf(s, "%32[0-9.dDeE] @ %32[-0-9.dDeE] , %32[0-9.dDeE] @ %32[-0-9.dDeE]", s1, s2, s3, s4) == 4){ dim1 = atof(s1); cen1 = atof(s2); dim2 = atof(s3); cen2 = atof(s4); *block = 1; itype = 1; got = 1; } else if(sscanf(s, "%32[0-9.dDeE] @ %32[-0-9.dDeE] , %32[0-9]", s1, s2, s3) == 3){ dim1 = atof(s1); cen1 = atof(s2); dim2 = dim1; cen2 = cen1; *block = MAX(1, strtol(s3, &t, 0)); itype = 1; got = 1; } else if(sscanf(s, "%32[0-9.dDeE] @ %32[-0-9.dDeE]", s1, s2) == 2){ dim1 = atof(s1); cen1 = atof(s2); dim2 = dim1; cen2 = cen1; itype = 1; got = 1; } /* if we are processing [email C++ strtoll函数代码示例 C++ strtok_s函数代码示例
|