c语言批量转PDF,C语言 批量产生文件名.pdf

C语言 批量产生文件名.pdf

程序中有时候,我们需要生成多个文件名连续的文件,那么我们就需要用到函数

sprintf, swprintf

int sprintf( char *buffer, const char *format [, argument] ... );

int swprintf( wchar_t *buffer, const wchar_t *format [, argument] ... );

Routine Required Header Compatibility

sprintf ANSI, Win 95, Win NT

swprintf or ANSI, Win 95, Win NT

Libraries

LIBC.LIB Single thread static library, retail version

LIBCMT.LIB Multithread static library, retail version

MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

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.

Parameters

buffer

Storage location for output

format

Format-control string

argument

Optional arguments

批量生成文件名为 Beauty01.bmp,Beauty02.bmp,Beauty03.bmp

/*批量生成文件名为 Beauty01.txt,Beauty02.txt,Beauty03.txt

内容写文件名*/

#include

#include

int main()

{

unsigned char file_name[15];

unsigned i;

for(i=1;i<=9;i++)

{

sprintf(file_name,"Beauty%02d.txt",i);

freopen(file_name,"wb",stdout);

printf("%s\n",file_name);

}

return 0;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值