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语言)


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

查看所有标签

猜你喜欢:

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

数据结构与算法分析

数据结构与算法分析

韦斯 / 机械工业 / 2007-1 / 55.00元

本书是国外数据结构与算法分析方面的标准教材,使用最卓越的Java编程语言作为实现工具讨论了数据结构(组织大量数据的方法)和算法分析(对算法运行时间的估计)。   随着计算机速度的不断增加和功能的日益强大,人们对有效编程和算法分析的要求也在增长。本书把算法分析与最有效率的Java程序的开发有机地结合起来,深入分析每种算法,内容全面、缜密严格,并细致讲解精心构造程序的方法。   第......一起来看看 《数据结构与算法分析》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

MD5 加密
MD5 加密

MD5 加密工具