通讯录1.2
来源:互联网 发布:生产玩具知乎 编辑:程序博客网 时间:2024/05/21 11:14
1.用mstrcpy mstrcmp 代替了strcpy strcmp
2.新增write file函数,在程序最后创建一个文件把通讯录写入
void writefile(node head){int i = 0;FILE * file = fopen("./Addr_List", "w");if(file == NULL){perror("open:");return;}while(head->next != NULL){fprintf(file, "%d\n", i);fwrite(head->data.name, sizeof(char), 15, file);fwrite(head->data.num, sizeof(char), 15, file);fwrite(head->data.address, sizeof(char), 15, file);fprintf(file,"\n");head = head->next;i++;}fprintf(file, "%d\n", i);fwrite(head->data.name, sizeof(char), 15, file);fwrite(head->data.num, sizeof(char), 15, file);fwrite(head->data.address, sizeof(char), 15, file);fprintf(file,"\n");fclose(file);return;}
char* mstrcpy(char a[], const char * str){int i = 0;while(*(str + i) != '\0'){a[i] = *(str + i);i++;}a[i] = *(str + i);return a;}int mstrcmp(const char a[], const char b[]){int i = 0;while(a[i] == b[i] && a[i] != '\0'){i++;}if(a[i] > b[i]){return 1;}else if(a[i] < b[i]){return -1;}return 0;}
阅读全文
0 0
- 通讯录1.2
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 将idea的java web项目导入eclipse
- Linux多线程编程
- LeetCode 486. Predict the Winner
- 夏泽网
- 禁止外网直接访问tomcat8080端口
- 通讯录1.2
- MTK平台驱动调试笔记
- Spring AOP详解
- Oracle杀死一直在执行且不停的存储
- 使用WebSocket设计简单聊天软件的雏形
- 最强大的代码编辑器(IDE)——Atom。Atom介绍安装与插件配置(一)
- Git常用命令-后续持续更新~~~
- Android图像处理_老照片效果md
- 浏览器内核的解析和对比