先来看个程序

#include

void main( void )

{

char  buffer[200], s[] = "computer", c = 'l';

int   i = 35, j = 0;

float fp = 1.7320534f;

j  = sprintf( buffer, "String:%s/n", s);

cout<

cout<

j += sprintf( buffer + j, "Character:%c/n", c);

cout<

cout<

j += sprintf( buffer + j, "/tInteger:%d/n", i);

cout<

cout<

j += sprintf( buffer + j, "/tReal:%f", fp);

cout<

printf( "Output:/n%s/ncharacter count = %d/n", buffer, j );

}

sprintf, swprintf

@import url(MS-ITS:dsmsdn.chm::/html/msdn_ie4.css);

int sprintf( char *buffer,

const char *format [, argument] ...

);

int swprintf( wchar_t *buffer,

const wchar_t *format [, argument] ...

);

sprintf, swprintf

@import url(MS-ITS:dsmsdn.chm::/html/msdn_ie4.css);

sprintf returns the number of bytes stored in buffer, not

counting the terminating null character. swprintf returns the number of

wide characters stored in buffer, not counting the terminating null wide

character.

sprintf, swprintf

@import url(MS-ITS:dsmsdn.chm::/html/msdn_ie4.css);

Parameters

buffer

Storage location for output

format

Format-control string

argument

Optional arguments

sprintf的返回值是不包括空白终止符的字符个数,但是经过sprintf格式化后,int占2个字节,float占8个字节。。。。

再看下面程序

int main()

{

char s[]  = "computer";

cout<

cout<

char s1[100];

char* p= "haha";

int j = sprintf(s1, "/t%s", p);

cout<

cout<

return 0;

};

mysql sprintf_sprintf的用法相关推荐

  1. MySQL:讨人喜欢的 MySQL replace into 用法(insert into 的增强版)

    讨人喜欢的 MySQL replace into 用法(insert into 的增强版) 在向表中插入数据的时候,经常遇到这样的情况:1. 首先判断数据是否存在: 2. 如果不存在,则插入:3.如果 ...

  2. 【node】express中mysql的基本用法、连接池的使用、事务的回滚

    [node]express中mysql的基本用法.连接池的使用 安装mysql包 mysql的配置信息 mysql基本操作 查询mysql并渲染数据 mysql插入操作 首先在html页面写上< ...

  3. Linux下Mysql的查询用法

    Linux下Mysql的查询用法 一.Mysql的delete删除语法 1.删除数据库 2.删除数据库的表 二.查询数据 1.基本查询 2.条件查询 三.数据库插入数据 1.创建新表 2.插入数据 四 ...

  4. MySQL replace into 用法

    MySQL replace into 用法(insert into 的增强版) 在向表中插入数据的时候,经常遇到这样的情况:1. 首先判断数据是否存在: 2. 如果不存在,则插入:3.如果存在,则更新 ...

  5. Mysql临时表的用法 - 51CTO.COM

    Mysql临时表的用法 - 51CTO.COM Mysql临时表我们经常会用到,下面就为您详细介绍Mysql临时表的用法,供您参考,如果您对此方面感兴趣的话,不妨一看. 当工作在非常大的表上时,你可能 ...

  6. mysql中as用法

    重命名列名或者表名. as可理解为:用作.当成,作为:一般是重命名列名或者表名.(主要为了查询方便) 重命名列.如:表text, 列 column_1,column_2 你可以写成: 1 select ...

  7. mysql alter怎么用,mysql alter话语用法

    mysql alter语句用法 //主键 ALTER TABLE tablename add new_field_id int(5) UNSIGNED DEFAULT 0 NOT NULL anto_ ...

  8. pdo mysql limit_PHP mysql中limit用法详解(代码示例)

    在MySQL中,LIMIT子句与SELECT语句一起使用,以限制结果集中的行数.LIMIT子句接受一个或两个offset和count的参数.这两个参数的值都可以是零或正整数. offset:用于指定要 ...

  9. [转载]MySQL exists的用法介绍

    原文摘自:http://www.cnblogs.com/glory-jzx/archive/2012/07/19/2599215.html MySQL exists的用法介绍 有一个查询如下: 1 S ...

最新文章

  1. Apache Mina开发手册
  2. VC++ 实现文件与应用程序关联
  3. Spring配置文件中的细节
  4. CF1580B Mathematics Curriculum(笛卡尔树、树形dp)
  5. Windows平台下如何实现Unity3D下的RTMP推送
  6. Codeforces Round #228 (Div. 2)
  7. threading模块的使用
  8. vs2013 创建MVC4项目出错。找不到指定的文件.(Exception HRESULT:08x0070002)
  9. CF1042D Petya and Array
  10. 操作元素-改变元素内容
  11. 802.11 对于multicast 和 broadcast的处理
  12. (秒杀项目) 4.5 项目部署与压测
  13. u)dym)l$_@3*0y3u_pvy@34ky1co1j$lfd1wp-w*8x%30@f7t$
  14. 恒生电子工作、学习经验总结#3
  15. inc si指令的作用_8086指令
  16. matlab在数字传输系统,数字基带传输系统matlab仿真.doc
  17. 【.Net码农】c#打印机设置,取得打印机列表及相应打印机的所有纸张格式
  18. 云服务器vCPU和CPU有什么区别?
  19. 10个微型计算机应用的例子,微型计算机原理与接口技术 复习资料
  20. #BDA#笔记#业务知识:常见行业业务模式指标6零售行业

热门文章

  1. 大屏手机有啥好?看看荣耀x30 Max就知道
  2. 新图网-免抠素材下载
  3. Kali Linux系统时间同步
  4. 体会-师傅领进门修行在个人
  5. 陌陌Q2财报解读:探探将成增值业务重要增长点
  6. ios11科学计算机,最新的iOS11居然这么强大,各种逆天功能...
  7. 关于右键Git Bash Here不能使用问题
  8. mysql索引添加缓慢_mysql 中 创建索引很慢,怎么解决
  9. Python算法实战视频课程--栈的应用-刘硕-专题视频课程
  10. 2021山西孕博会|山西产康展会|山西月子展会