现在的位置: 首页 > 综合 > 正文

scanf

2013年10月01日 ⁄ 综合 ⁄ 共 466字 ⁄ 字号 评论关闭
// scanfXS.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int main(int argc, char* argv[])
{
	int i;
	char buff[256];

	printf("please input an int number:\n");
	scanf("%x",&i);
    printf("i=%x\n",i);
	printf("please input a  string:\n");
	scanf("%s",buff);
    printf("string=%s\n",buff);

	return 0;
}
/*
please input an int number:
0xad
i=ad
please input a  string:
qwert321
string=qwert321
Press any key to continue
please input an int number:
ad
i=ad
please input a  string:
asdfg
string=asdfg
Press any key to continue
*/

抱歉!评论已关闭.