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

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

内容简介:感谢倾璇、晏子霜师傅的教导,学习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语言)


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

查看所有标签

猜你喜欢:

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

Distributed Algorithms

Distributed Algorithms

Wan Fokkink / The MIT Press / 2013-12-6 / USD 40.00

This book offers students and researchers a guide to distributed algorithms that emphasizes examples and exercises rather than the intricacies of mathematical models. It avoids mathematical argumentat......一起来看看 《Distributed Algorithms》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

MD5 加密
MD5 加密

MD5 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具