首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

sscanf(a+h,"%s"ch);这句是什么意思,该如何解决

2012-03-14 
sscanf(a+h,%s,ch)这句是什么意思char a[100],ch[100][解决办法]h的值是多少?就是从指针a开始偏移h的

sscanf(a+h,"%s",ch);这句是什么意思
char a[100],ch[100];

[解决办法]
h的值是多少?
就是从指针a开始偏移h的地方,读一个字符串出来,存在ch里。
[解决办法]
int sscanf( const char *buffer, const char *format [, argument ] ... );

Parameters
buffer 
Stored data 
format 
Format-control string 
argument 
Optional arguments 
Libraries
All versions of the C run-time libraries.

Return Value
Each of these functions returns the number of fields successfully converted and assigned; the return value does not include fields that were read but not assigned. A return value of 0 indicates that no fields were assigned. The return value is EOF for an error or if the end of the string is reached before the first conversion.

简单的说:从a+h处取一个字符串,存放到ch处
[解决办法]

探讨

为什么我puts(ch);不能输出ch里的内容?

[解决办法]
向ch写入的是从a偏移h个位置的内容,数组足够大的前提下输出a的后面一部分
探讨

sscanf(a+h,"%s",ch);这个语句不是把a数组的数存入ch里吗?
那我输出ch是应该可以输出a的数组的内容吗?

热点排行