内容简介:感谢倾璇、晏子霜师傅的教导,学习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);
}
运行:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 使用Go语言创建WebSocket服务
- 使用 Go 语言创建 WebSocket 服务
- 使用 Go 语言创建 WebSocket 服务
- 编程语言 – 哪些语言允许创建跨平台的本机可执行文件?
- Go语言五种变量创建的方法
- 使用Go语言创建静态文件服务器
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
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》 这本书的介绍吧!