Jump to content
Sign in to follow this  
Graf

[c++] Аналог _TRUNCATE и _snprintf_s

Recommended Posts

Добрый день.

Разбирая моды V3ctor столкнулся с проблемой, что "_TRUNCATE" не используется в старых версиях VS, как и "_snprintf_s"

Помогите найти аналог, пожалуйста.

Пример строки:

_snprintf_s(buf, _TRUNCATE, "%.2d:%.2d", hours, minutes);

 

Edited by Graf

Share this post


Link to post
Share on other sites

Привет, @Graf!

 

Ты можешь использовать функцию sprintf()

int sprintf ( char * str, const char * format, ... );

Например, 

sprintf(buf, "%.2d:%.2d", hours, minutes);

но тебе нужно будет позаботиться, что размер результирующей строки не будет превышать размер буфера (buf), иначе программа упадет.

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...