Jekyll文章创建程序(C语言)

栏目: C · 发布时间: 5年前

内容简介:感谢倾璇、晏子霜师傅的教导,学习C语言的道路上,个人的第一个C语言小程序诞生了…希望自己接下来的学习可以戒骄戒躁!代码如下:

感谢倾璇、晏子霜师傅的教导,学习 C语言 的道路上,个人的第一个C语言小程序诞生了…

希望自己接下来的学习可以戒骄戒躁!

代码如下:

#include <stdio.h>
#include <time.h>
#include <string.h>

char t[15];

struct initArticle{
	char title[50];
	char author[50];
	char dtime[15];
	char permalink[30];
	char description[200];
};

typedef struct initArticle Paper;

int getTime(){
	time_t rawtime;
	struct tm *info;
	int year, month, day;
	time(&rawtime);
	info = localtime(&rawtime);
	year = 1900+(info->tm_year);
	month = info->tm_mon+1;
	day = info->tm_mday;
	sprintf(t, "%d-0%d-%d", year, month, day);
	return 0;
}

int main(int argc, char *argv[]){
	getTime();
	Paper p;
	argv[1][15] = '\0';
	argv[2][5] = '\0';
	char *dt[15];
	*dt = t;

	char plink[30];
	sprintf(plink, "/archives/%s/%s", t, argv[2]);

	strcpy(p.dtime, *dt);
	strcpy(p.permalink, plink);
	strcpy(p.author, "Vulkey_Chen");

	printf("Title: ");
	scanf("%s", p.title);

	printf("Description: ");
	scanf("%s", p.description);

	FILE *fp = NULL;
	strcat(t, "-");
	strcat(t, argv[1]);
	strcat(t, ".md");
	//printf("%s %s", *dt, plink);
	fp = fopen(t, "w");
	fprintf(fp, "---\nlayout: post\nauthor: %s\ntitle: \"%s\"\ndate: %s\npermalink: %s\ndescription: \"%s\"\n---", p.author, p.title, p.dtime, p.permalink, p.description);
	fclose(fp);
	printf("File: [%s], create successfully!\n", t);
}

运行:

Jekyll文章创建程序(C语言)


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Operating Systems

Operating Systems

Remzi Arpaci-Dusseau、Andrea Arpaci-Dusseau / Arpaci-Dusseau Books / 2012-8-19 / USD 21.00

A book about modern operating systems. Topics are broken down into three major conceptual pieces: Virtualization, Concurrency, and Persistence. Includes all major components of modern systems includin......一起来看看 《Operating Systems》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具