您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ strnfmt函数代码示例

51自学网 2021-06-03 08:31:44
  C++
这篇教程C++ strnfmt函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中strnfmt函数的典型用法代码示例。如果您正苦于以下问题:C++ strnfmt函数的具体用法?C++ strnfmt怎么用?C++ strnfmt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了strnfmt函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: strnfmt

static const char *show_speed(void){	static char buffer[10];	int tmp = player->state.speed;	if (player->timed[TMD_FAST]) tmp -= 10;	if (player->timed[TMD_SLOW]) tmp += 10;	if (tmp == 110) return "Normal";	strnfmt(buffer, sizeof(buffer), "%d", tmp - 110);	return buffer;}
开发者ID:HaoDrang,项目名称:angband,代码行数:10,


示例2: get_curse_display

/** * Display an entry on the item menu */void get_curse_display(struct menu *menu, int oid, bool cursor, int row,					  int col, int width){	struct curse **choice = menu_priv(menu);	int attr = cursor ? COLOUR_L_BLUE : COLOUR_WHITE;	char buf[80];	int power = choice[oid]->power;	strnfmt(buf, sizeof(buf), "%s (power %d)", choice[oid]->name, power);	c_put_str(attr, buf, row + oid, col);}
开发者ID:fe051,项目名称:angband,代码行数:13,


示例3: race_aux_hook

/* * Display additional information about each race during the selection. */static void race_aux_hook(birth_menu r_str){	int race, i, adj;	char s[50];	byte attr;	/* Extract the proper race index from the string. */	for (race = 0; race < z_info->p_max; race++)	{		if (!strcmp(r_str.name, p_name + p_info[race].name)) break;	}	if (race == z_info->p_max) return;	/* Display the stats */	for (i = 0; i < A_MAX; i++)	{		/*dump the stats*/		strnfmt(s, sizeof(s), "%s", stat_names[i]);		Term_putstr(RACE_AUX_COL, TABLE_ROW + i, -1, TERM_WHITE, s);				adj = p_info[race].r_adj[i];		strnfmt(s, sizeof(s), "%+d", adj);				if (adj < 0)		attr = TERM_RED;		else if (adj == 0)	attr = TERM_L_DARK;		else if (adj == 1)	attr = TERM_GREEN;		else if (adj == 2)	attr = TERM_L_GREEN;		else				attr = TERM_L_BLUE;				Term_putstr(RACE_AUX_COL + 4, TABLE_ROW + i, -1, attr, s);	}	/* Display the race flags */		Term_putstr(RACE_AUX_COL, TABLE_ROW + A_MAX + 1, -1, TERM_WHITE, "                    ");	Term_putstr(RACE_AUX_COL, TABLE_ROW + A_MAX + 2, -1, TERM_WHITE, "                    ");	Term_putstr(RACE_AUX_COL, TABLE_ROW + A_MAX + 3, -1, TERM_WHITE, "                    ");	Term_putstr(RACE_AUX_COL, TABLE_ROW + A_MAX + 4, -1, TERM_WHITE, "                    ");		print_rh_flags(race, 0, RACE_AUX_COL, TABLE_ROW + A_MAX + 1);	}
开发者ID:halfsickofshadows,项目名称:Sil,代码行数:46,


示例4: prt_sp

/* * Prints players max/cur spell points */static void prt_sp(int row, int col){    char cur_sp[32], max_sp[32];    byte color = player_sp_attr();    /* Do not show mana unless we have some */    if (!p_ptr->msp)	return;    put_str("SP ", row, col);    strnfmt(max_sp, sizeof(max_sp), "%4d", p_ptr->msp);    strnfmt(cur_sp, sizeof(cur_sp), "%4d", p_ptr->csp);    /* Show mana */    c_put_str(color, cur_sp, row, col + 3);    c_put_str(TERM_WHITE, "/", row, col + 7);    c_put_str(TERM_L_GREEN, max_sp, row, col + 8);}
开发者ID:artes-liberales,项目名称:FAangband,代码行数:22,


示例5: strnfmt

static const char *show_depth(void){	static char buffer[13];	if (player->max_depth == 0) return "Town";	strnfmt(buffer, sizeof(buffer), "%d' (L%d)",	        player->max_depth * 50, player->max_depth);	return buffer;}
开发者ID:NickMcConnell,项目名称:angband,代码行数:10,


示例6: cnv_stat

/* * Converts stat num into a six-char (right justified) string */void cnv_stat(int val, char *out_val, size_t out_len){    /* Above 18 */    if (val > 18) {	int bonus = (val - 18);	if (bonus >= 220)	    strnfmt(out_val, out_len, "18/***");	else if (bonus >= 100)	    strnfmt(out_val, out_len, "18/%03d", bonus);	else	    strnfmt(out_val, out_len, " 18/%02d", bonus);    }    /* From 3 to 18 */    else {	strnfmt(out_val, out_len, "    %2d", val);    }}
开发者ID:artes-liberales,项目名称:FAangband,代码行数:22,


示例7: describe_origin

/** * Describe an item's origin */static bool describe_origin(textblock *tb, const struct object *obj, bool terse){	char loot_spot[80];	char name[80];	int origin;	const char *droppee;	const char *article;	/* Only give this info in chardumps if wieldable */	if (terse && !obj_can_wear(obj))		return false;	/* Set the origin - care needed for mimics */	if ((obj->origin == ORIGIN_DROP_MIMIC) && (obj->mimicking_m_idx != 0))		origin = ORIGIN_FLOOR;	else		origin = obj->origin;	/* Name the place of origin */	if (obj->origin_depth)		strnfmt(loot_spot, sizeof(loot_spot), "at %d feet (level %d)",		        obj->origin_depth * 50, obj->origin_depth);	else		my_strcpy(loot_spot, "in town", sizeof(loot_spot));	/* Name the monster of origin */	if (r_info[obj->origin_xtra].ridx)		droppee = r_info[obj->origin_xtra].name;	else		droppee = "monster lost to history";	article = is_a_vowel(droppee[0]) ? "an " : "a ";	if (rf_has(r_info[obj->origin_xtra].flags, RF_UNIQUE))		my_strcpy(name, droppee, sizeof(name));	else {		my_strcpy(name, article, sizeof(name));		my_strcat(name, droppee, sizeof(name));	}	/* Print an appropriate description */	switch (origins[origin].args)	{		case -1: return false;		case 0: textblock_append(tb, origins[origin].desc); break;		case 1: textblock_append(tb, origins[origin].desc, loot_spot);				break;		case 2:			textblock_append(tb, origins[origin].desc, name, loot_spot);			break;	}	textblock_append(tb, "/n/n");	return true;}
开发者ID:Chillbon,项目名称:angband,代码行数:57,


示例8: project_player_handler_FORCE

static void project_player_handler_FORCE(project_player_handler_context_t *context){	char grids_away[5];	/* Stun */	(void)player_inc_timed(player, TMD_STUN, randint1(20), true, true);	/* Thrust player away. */	strnfmt(grids_away, sizeof(grids_away), "%d", 3 + context->dam / 20);	effect_simple(EF_THRUST_AWAY, context->origin, grids_away, context->y, context->x, 0, NULL);}
开发者ID:datatypevoid,项目名称:angband,代码行数:11,


示例9: get_curse_display

/** * Display an entry on the item menu */void get_curse_display(struct menu *menu, int oid, bool cursor, int row,					  int col, int width){	struct curse_menu_data *choice = menu_priv(menu);	int attr = cursor ? COLOUR_L_BLUE : COLOUR_WHITE;	char buf[80];	int power = choice[oid].power;	char *name = curses[choice[oid].index].name;	strnfmt(buf, sizeof(buf), "  %s (curse strength %d)", name, power);	c_put_str(attr, buf, row, col);}
开发者ID:NickMcConnell,项目名称:angband,代码行数:15,


示例10: strnfmt

static const char *show_adv_exp(void){	if (player->lev < PY_MAX_LEVEL) {		static char buffer[30];		s32b advance = (player_exp[player->lev - 1] * player->expfact / 100L);		strnfmt(buffer, sizeof(buffer), "%d", advance);		return buffer;	}	else {		return "********";	}}
开发者ID:angband,项目名称:angband,代码行数:12,


示例11: item_menu_browser

/** * Show quiver missiles in full inventory */static void item_menu_browser(int oid, void *data, const region *area){	char tmp_val[80];	int count, j, i = num_obj;	int quiver_slots = (player->upkeep->quiver_cnt + z_info->stack_size - 1)		/ z_info->stack_size;	/* Set up to output below the menu */	text_out_hook = text_out_to_screen;	text_out_wrap = 0;	text_out_indent = area->col - 1;	text_out_pad = 1;	prt("", area->row + area->page_rows, MAX(0, area->col - 1));	Term_gotoxy(area->col, area->row + area->page_rows);	/* Quiver may take multiple lines */	for (j = 0; j < quiver_slots; j++, i++) {		const char *fmt = "in Quiver: %d missile%s/n";		char letter = I2A(i);		/* Number of missiles in this "slot" */		if (j == quiver_slots - 1)			count = player->upkeep->quiver_cnt - (z_info->stack_size *													  (quiver_slots - 1));		else			count = z_info->stack_size;		/* Print the (disabled) label */		strnfmt(tmp_val, sizeof(tmp_val), "%c) ", letter);		text_out_c(COLOUR_SLATE, tmp_val, area->row + i, area->col);		/* Print the count */		strnfmt(tmp_val, sizeof(tmp_val), fmt, count,				count == 1 ? "" : "s");		text_out_c(COLOUR_L_UMBER, tmp_val, area->row + i, area->col + 3);	}	text_out_pad = 0;	text_out_indent = 0;}
开发者ID:danaris,项目名称:tgcangband,代码行数:43,


示例12: textui_get_quantity

/** * Request a "quantity" from the user */int textui_get_quantity(const char *prompt, int max){    int amt = 1;    /* Prompt if needed */    if (max != 1) {        char tmp[80];        char buf[80];        /* Build a prompt if needed */        if (!prompt) {            /* Build a prompt */            strnfmt(tmp, sizeof(tmp), "Quantity (0-%d, *=all): ", max);            /* Use that prompt */            prompt = tmp;        }        /* Build the default */        strnfmt(buf, sizeof(buf), "%d", amt);        /* Ask for a quantity */        if (!get_string(prompt, buf, 7)) return (0);        /* Extract a number */        amt = atoi(buf);        /* A star or letter means "all" */        if ((buf[0] == '*') || isalpha((unsigned char)buf[0])) amt = max;    }    /* Enforce the maximum */    if (amt > max) amt = max;    /* Enforce the minimum */    if (amt < 0) amt = 0;    /* Return the result */    return (amt);}
开发者ID:pete-mack,项目名称:angband,代码行数:43,


示例13: center_string

/* * Centers a string within a 31 character string */static void center_string(char *buf, size_t len, cptr str){	int i, j;	/* Total length */	i = strlen(str);	/* Necessary border */	j = 15 - i / 2;	/* Mega-Hack */	strnfmt(buf, len, "%*s%s%*s", j, "", str, 31 - i - j, "");}
开发者ID:tingley,项目名称:tactical,代码行数:16,


示例14: lookup_symbol

/* * Search the monster, item, and feature types to find the * meaning for the given symbol. * * Note: We currently search items first, then features, then * monsters, and we return the first hit for a symbol. * This is to prevent mimics and lurkers from matching * a symbol instead of the item or feature it is mimicking. * * Todo: concatenate all matches into buf. This will be much * easier once we can loop through item tvals instead of items * (see note below.) * * Todo: Should this take the user's pref files into account? */static void lookup_symbol(struct keypress sym, char *buf, size_t max){	int i;	monster_base *race;	/* Look through items */	/* Note: We currently look through all items, and grab the tval when we find a match.	It would make more sense to loop through tvals, but then we need to associate	a display character with each tval. */	for (i = 1; i < z_info->k_max; i++) {		if (k_info[i].d_char == (char)sym.code) {			strnfmt(buf, max, "%c - %s.", (char)sym.code, tval_find_name(k_info[i].tval));			return;		}	}	/* Look through features */	/* Note: We need a better way of doing this. Currently '#' matches secret door,	and '^' matches trap door (instead of the more generic "trap"). */	for (i = 1; i < z_info->f_max; i++) {		if (f_info[i].d_char == (char)sym.code) {			strnfmt(buf, max, "%c - %s.", (char)sym.code, f_info[i].name);			return;		}	}		/* Look through monster templates */	for (race = rb_info; race; race = race->next){		if ((char)sym.code == race->d_char) {			strnfmt(buf, max, "%c - %s.", (char)sym.code, race->text);			return;		}	}	/* No matches */	strnfmt(buf, max, "%c - %s.", (char)sym.code, "Unknown Symbol");		return;}
开发者ID:CJNyfalt,项目名称:angband,代码行数:54,


示例15: module_reset_dir_aux

static void module_reset_dir_aux(cptr *dir, cptr new_path){	char buf[1024];	/* Build the new path */	strnfmt(buf, sizeof (buf), "%s%s%s", dir, PATH_SEP, new_path);	string_free(*dir);	*dir = string_make(buf);	/* Make it if needed */	if (!private_check_user_directory(*dir))		quit(format("Unable to create module dir %s/n", *dir));}
开发者ID:AmyBSOD,项目名称:ToME-SX,代码行数:14,


示例16: user_name

/* * Find a default user name from the system. */static void user_name(char *buf, size_t len, int id){	struct passwd *pw = getpwuid(id);	/* Default to PLAYER */	if (!pw)	{		my_strcpy(buf, "PLAYER", len);		return;	}	/* Capitalise and copy */	strnfmt(buf, len, "%^s", pw->pw_name);}
开发者ID:Colt374,项目名称:angband,代码行数:17,


示例17: do_cs

/* * Restrict scrolling to within these rows */static void do_cs(int y1, int y2){#ifdef USE_TERMCAP	if (cs) tp(tgoto(cs, y2, y1));#endif#ifdef USE_HARDCODE	char temp[64];	strnfmt(temp, sizeof(temp), cs, y1, y2);	tp (temp);#endif}
开发者ID:MarvinPA,项目名称:mpa-sil,代码行数:17,


示例18: prt_level

/* * Prints level */static void prt_level(int row, int col){    char tmp[32];    strnfmt(tmp, sizeof(tmp), "%6d", p_ptr->lev);    if (p_ptr->lev >= p_ptr->max_lev) {	put_str("LEVEL ", row, col);	c_put_str(TERM_L_GREEN, tmp, row, col + 6);    } else {	put_str("Level ", row, col);	c_put_str(TERM_YELLOW, tmp, row, col + 6);    }}
开发者ID:artes-liberales,项目名称:FAangband,代码行数:17,


示例19: do_cm

/* * Go to the given screen location directly */static void do_cm(int x, int y){#ifdef USE_TERMCAP	if (cm) tp(tgoto(cm, x, y));#endif#ifdef USE_HARDCODE	char temp[64];	strnfmt(temp, sizeof(temp), cm, y+1, x+1);	tp(temp);#endif}
开发者ID:MarvinPA,项目名称:mpa-sil,代码行数:17,


示例20: save_game

/** * Save the game */void save_game(void){	char name[80];	char path[1024];	/* Disturb the player */	disturb(player, 1);	/* Clear messages */	event_signal(EVENT_MESSAGE_FLUSH);	/* Handle stuff */	handle_stuff(player);	/* Message */	prt("Saving game...", 0, 0);	/* Refresh */	Term_fresh();	/* The player is not dead */	my_strcpy(player->died_from, "(saved)", sizeof(player->died_from));	/* Forbid suspend */	signals_ignore_tstp();	/* Save the player */	if (savefile_save(savefile))		prt("Saving game... done.", 0, 0);	else		prt("Saving game... failed!", 0, 0);	/* Refresh */	Term_fresh();	/* Save the window prefs */	strnfmt(name, sizeof(name), "%s.prf", player_safe_name(player, TRUE));	path_build(path, sizeof(path), ANGBAND_DIR_USER, name);	if (!prefs_save(path, option_dump, "Dump window settings"))		prt("Failed to save subwindow preferences", 0, 0);	/* Allow suspend again */	signals_handle_tstp();	/* Refresh */	Term_fresh();	/* Note that the player is not dead */	my_strcpy(player->died_from, "(alive and well)", sizeof(player->died_from));}
开发者ID:NickMcConnell,项目名称:FirstAgeAngband,代码行数:53,


示例21: do_cmd_wiz_jump

/* * Go to any level */static void do_cmd_wiz_jump(void){	/* Ask for level */	if (p_ptr->command_arg <= 0)	{		char ppp[80];		char tmp_val[160];		/* Prompt */		strnfmt(ppp, sizeof(ppp), "Jump to level (0-%d): ", MAX_DEPTH-1);		/* Default */		strnfmt(tmp_val, sizeof(tmp_val), "%d", p_ptr->depth);		/* Ask for a level */		if (!get_string(ppp, tmp_val, 11)) return;		/* Extract request */		p_ptr->command_arg = atoi(tmp_val);	}	/* Paranoia */	if (p_ptr->command_arg < 0) p_ptr->command_arg = 0;	/* Paranoia */	if (p_ptr->command_arg > MAX_DEPTH - 1) p_ptr->command_arg = MAX_DEPTH - 1;	/* Accept request */	msg("You jump to dungeon level %d.", p_ptr->command_arg);	/* New depth */	p_ptr->depth = p_ptr->command_arg;	/* Leaving */	p_ptr->leaving = TRUE;}
开发者ID:mtadd,项目名称:angband,代码行数:40,


示例22: o_xtra_act

/* * Special key actions for object inscription. */static void o_xtra_act(struct keypress ch, int oid){	object_kind *k_ptr = &k_info[oid];	s16b idx = get_autoinscription_index(oid);	/* Forget it if we've never seen the thing */	if (!k_ptr->everseen)		return;	/* Uninscribe */	if (ch.code == '}') {		if (idx != -1)			remove_autoinscription(oid);		return;	}	/* Inscribe */	else if (ch.code == '{') {		char note_text[80] = "";		/* Avoid the prompt getting in the way */		screen_save();		/* Prompt */		prt("Inscribe with: ", 0, 0);		/* Default note */		if (idx != -1)			strnfmt(note_text, sizeof(note_text), "%s",					get_autoinscription(oid));		/* Get an inscription */		if (askfor_aux(note_text, sizeof(note_text), NULL)) {			/* Remove old inscription if existent */			if (idx != -1)				remove_autoinscription(oid);			/* Add the autoinscription */			add_autoinscription(oid, note_text);			/* Notice stuff (later) */			p_ptr->notice |= (PN_AUTOINSCRIBE);			p_ptr->redraw |= (PR_INVEN | PR_EQUIP);		}		/* Reload the screen */		screen_load();	}}
开发者ID:NickMcConnell,项目名称:Beleriand,代码行数:52,


示例23: strnfmt

static const char *show_missile_weapon(const object_type *o_ptr){	static char buffer[12];	int hit = p_ptr->state.dis_to_h;	int dam = 0;	if (object_attack_plusses_are_visible(o_ptr))	{		hit += o_ptr->to_h;		dam += o_ptr->to_d;	}	strnfmt(buffer, sizeof(buffer), "(%+d,%+d)", hit, dam);	return buffer;}
开发者ID:creidieki,项目名称:angband,代码行数:15,


示例24: print_history_header

static void print_history_header(void){    char buf[80];    /* Print the header (character name and title) */    strnfmt(buf, sizeof(buf), "%s the %s %s", op_ptr->full_name,	    rp_ptr->name, cp_ptr->name);    c_put_str(TERM_WHITE, buf, 0, 0);    c_put_str(TERM_WHITE, "============================================================", 1, 0);    c_put_str(TERM_WHITE, "CHAR.", 2, 34);    c_put_str(TERM_WHITE, "|   TURN  |      LOCATION        |LEVEL| EVENT",	      3, 0);    c_put_str(TERM_WHITE, "============================================================", 4, 0);}
开发者ID:LostTemplar,项目名称:Beleriand,代码行数:15,


示例25: uninscribe

/* * Helper function which actually removes the inscription */void uninscribe(object_type *o_ptr){	/* Remove the inscription */	o_ptr->obj_note = 0;		/*The object kind has an autoinscription*/	// Sil-y: removed restriction to known items (through 'object_aware')	if (!(k_info[o_ptr->k_idx].flags3 & (TR3_INSTA_ART)) &&	    (get_autoinscription_index(o_ptr->k_idx) != -1))	{		char tmp_val[160];		char o_name2[80];				/*make a fake object so we can give a proper message*/		object_type *i_ptr;		object_type object_type_body;				/* Get local object */		i_ptr = &object_type_body;				/* Wipe the object */		object_wipe(i_ptr);				/* Create the object */		object_prep(i_ptr, o_ptr->k_idx);				/*make it plural*/		i_ptr->number = 2;				/*now describe with correct amount*/		object_desc(o_name2, sizeof(o_name2), i_ptr, FALSE, 0);				/* Prompt */		strnfmt(tmp_val, sizeof(tmp_val), "Remove automatic inscription for %s? ", o_name2);				/* Auto-Inscribe if they want that */		if (get_check(tmp_val)) obliterate_autoinscription(o_ptr->k_idx);	}		/* Message */	msg_print("Inscription removed.");		/* Combine the pack */	p_ptr->notice |= (PN_COMBINE);		/* Window stuff */	p_ptr->window |= (PW_INVEN | PW_EQUIP);}
开发者ID:fph,项目名称:mortsil,代码行数:51,


示例26: borg_oops_aux

/* * Abort the Borg, noting the reason */static void borg_oops_aux(cptr what){	char buf[1024];	/* Stop processing */	borg_active = FALSE;	/* Format the string */	(void)strnfmt(buf, 1024, "# Aborting (%s).", what);	/* Give a warning */	borg_note(buf);	/* Forget borg keys */	borg_flush();}
开发者ID:jcheatham,项目名称:Zangband,代码行数:19,


示例27: wr_description

/* * Write a description of the character */void wr_description(void){	char buf[1024];	if (p_ptr->is_dead)		strnfmt(buf, sizeof buf, "%s, dead (%s)", op_ptr->full_name, p_ptr->died_from);	else		strnfmt(buf, sizeof buf, "%s, L%d %s %s, at DL%d",				op_ptr->full_name,				p_ptr->lev,				p_ptr->race->name,				p_ptr->class->name,				p_ptr->depth);	wr_string(buf);}
开发者ID:DaPortlyJester,项目名称:angband,代码行数:19,


示例28: get_check

/* * Verify something with the user * * The "prompt" should take the form "Query? " * * Note that "[y/n]" is appended to the prompt. */bool get_check(const char *prompt){	//struct keypress ke;	ui_event ke;	char buf[80];	bool repeat = FALSE;  	/* Paranoia XXX XXX XXX */	message_flush();	/* Hack -- Build a "useful" prompt */	strnfmt(buf, 78, "%.70s[y/n] ", prompt);	/* Hack - kill the repeat button */	if (button_kill('n')) repeat = TRUE;		/* Make some buttons */	button_add("[y]", 'y');	button_add("[n]", 'n');	redraw_stuff(p_ptr);  	/* Prompt for it */	prt(buf, 0, 0);	ke = inkey_m();	/* Kill the buttons */	button_kill('y');	button_kill('n');	/* Hack - restore the repeat button */	if (repeat) button_add("[Rpt]", 'n');	redraw_stuff(p_ptr);  	/* Erase the prompt */	prt("", 0, 0);	/* Normal negation */	if (ke.type == EVT_MOUSE) {		if ((ke.mouse.button != 1) && (ke.mouse.y != 0)) return (FALSE);	} else	if ((ke.key.code != 'Y') && (ke.key.code != 'y')) return (FALSE);	/* Success */	return (TRUE);}
开发者ID:Kilumanjaro,项目名称:angband,代码行数:54,


示例29: get_item_allow

/* * Hack -- prevent certain choices depending on the inscriptions on the item. * * The item can be negative to mean "item on floor". */bool get_item_allow(int item, unsigned char ch, cmd_code cmd, bool is_harmless){	object_type *o_ptr;	char verify_inscrip[] = "!*";	unsigned n;	/* Inventory or floor */	if (item >= 0)		o_ptr = &p_ptr->inventory[item];	else		o_ptr = object_byid(0 - item);	/* Hack - Only shift the command key if it actually needs to be shifted. */	if (ch < 0x20)		ch = UN_KTRL(ch);	/* The inscription to look for */	verify_inscrip[1] = ch;	/* Look for the inscription */	n = check_for_inscrip(o_ptr, verify_inscrip);	/* Also look for for the inscription '!*' */	if (!is_harmless)		n += check_for_inscrip(o_ptr, "!*");	/* Choose string for the prompt */	if (n) {		char prompt[1024];		const char *verb = cmd_get_verb(cmd);		if (!verb)			verb = "do that with";		strnfmt(prompt, sizeof(prompt), "Really %s", verb);		/* Promt for confirmation n times */		while (n--) {			if (!verify_item(prompt, item))				return (FALSE);		}	}	/* Allow it */	return (TRUE);}
开发者ID:KertaLosataure,项目名称:angband,代码行数:52,


示例30: prt_depth

/* * Prints depth in stat area */static void prt_depth(int row, int col){	char depths[32];	if (!p_ptr->depth)	{		my_strcpy(depths, "Town", sizeof(depths));	}	else	{		strnfmt(depths, sizeof(depths), "%d' (L%d)",		        p_ptr->depth * 50, p_ptr->depth);	}	/* Right-Adjust the "depth", and clear old values */	put_str(format("%-13s", depths), row, col);}
开发者ID:cinereaste,项目名称:angband,代码行数:20,



注:本文中的strnfmt函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ strnicmp函数代码示例
C++ strnfcat函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。