鸟语天空
C语言—puts()
post by:追风剑情 2019-10-22 21:29

示例

//Visual Studio中加上这句才可以使用scanf()
//否则只能使用scanf_s()
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdbool.h>
//引入字符串函数string.h
//一些ANSI之前的系统使用strings.h头文件,而
//有些系统可能根本没有字符串头文件。
#include <string.h>

#define DEF "I am a #defined string."

//argc: 参数个数 argv[]: 参数数组
int main(int argc, char *argv[])
{
	char str1[80] = "An array was initialized to me.";
	const char * str2 = "A pointer was initialized to me.";
	puts("I'm an argument to puts().");
	puts(DEF);
	puts(str1);
	puts(str2);
	puts(&str1[5]);//从第6个元素处开始输出
	puts(str2 + 4);//从第5个元素处开始输出

	system("pause");
	return 0;
}

运行测试

1111.png

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容