/* SPRINTF.C: This program uses sprintf to format various
* data and place them in the string named buffer.
*/#include <stdio.h>void main( void )
{
char buffer[200], s[] = "computer", c = 'l';
int i = 35, j;
float fp = 1.7320534f; /* Format and print various data: */
j = sprintf( buffer, "\tString: %s\n", s );
j += sprintf( buffer + j, "\tCharacter: %c\n", c );
j += sprintf( buffer + j, "\tInteger: %d\n", i );
j += sprintf( buffer + j, "\tReal: %f\n", fp ); printf( "Output:\n%s\ncharacter count = %d\n", buffer, j );
}
我用sizeof()测了一下,int和char*占的空间都是4,那么j+=.... 这句就跑到下个BUFFER中了,那么前面的那个有多少个没有用??
* data and place them in the string named buffer.
*/#include <stdio.h>void main( void )
{
char buffer[200], s[] = "computer", c = 'l';
int i = 35, j;
float fp = 1.7320534f; /* Format and print various data: */
j = sprintf( buffer, "\tString: %s\n", s );
j += sprintf( buffer + j, "\tCharacter: %c\n", c );
j += sprintf( buffer + j, "\tInteger: %d\n", i );
j += sprintf( buffer + j, "\tReal: %f\n", fp ); printf( "Output:\n%s\ncharacter count = %d\n", buffer, j );
}
我用sizeof()测了一下,int和char*占的空间都是4,那么j+=.... 这句就跑到下个BUFFER中了,那么前面的那个有多少个没有用??
解决方案 »
- 请问CreateCompatibleDC与CreateCompatibleBitmap作用!(控件重绘源代码)
- 关于skin++等皮肤界面问题
- 有没有办法对VC FileView或解决方案资源管理器中的文件夹人工进行排序?
- 为什么我用Event事件不能fire
- 怎么为COM增加事件
- 急问:有谁知道.pdg文件用什么来读
- 郁闷!这一份代码在XP下可以运行,但在9X下有问题!!
- 什么地方可以找到win2000的ddk
- 想请教各位高手,如何知道各种文件的格式或算法?
- HELP!! HELP!! 函数发生冲突!请高手指点迷津!!!
- Runtime error是个什么错误?
- 用propertysheet做的wizard,怎样禁止右上角的X按钮啊?
我把相应的文件都加进去了,可是:
编译器报错: D:\MY_DEV_CPProject\Makefile.win [Build Error] [StringFormat.exe] Error 1 日志文件:
Default compiler
Building Makefile: "D:\MY_DEV_CPProject\Makefile.win"
执行 make...
make.exe -f "D:\MY_DEV_CPProject\Makefile.win" all
g++.exe -o "StringFormat.exe" -L"D:/Dev-Cpp/lib" g++.exe: no input filesmake.exe: *** [StringFormat.exe] Error 1执行结束
//////////////////////////////////////////
没有输入文件,所以再问一个问题,各位前辈都是如何快速的了解MSDN中一个函数的功能的,
并把他们的相应文件加入进去,并编译通过!!/////////////////////////////////////////////////////////////////////////////
我另开200的帖放分!!!!
我把相应的文件都加进去了,请问你!你为什么要加呢?加个“string.h”不就可以了吗
// ----------------------------------------------------------------------------- // Format.cpp: Implements functions to format and return CStrings. // // Copyright (C) Microsoft Corp. 1986-1996. All Rights Reserved.
//---------------------------------------------------------------------------- #include "edkafx.h"
#include "exadmin.h"
#include "format.h"
还包含了其他的头文件/////////////////////////////////////////////////////
上面的问题没人会吗???
前辈快来~~~~~~~~!!
不好的