c 简单程序
2015-07-20 11:08
169 查看
//从键盘输入一个目录文件名;
//打印.c文件,判断大括号是否成对出现;
//打印.c文件,判断大括号是否成对出现;
#include<stdio.h> int main() { FILE *Rfile = NULL; char *Pput=NULL; char name[100] = "0"; int count=5; char ch='0'; flag: printf("请输入你要读取的文件目录与名字(eg:c:\\windows\\test.c):\n"); scanf("%s",name); Rfile = fopen(name,"r"); if (Rfile == NULL) { printf("你要访问的文件不存在,请重新输入目录!\n"); goto flag; } else { while (ch != EOF) { ch = fgetc(Rfile); putchar(ch); } fclose(Rfile); Rfile = fopen(name, "r"); ch = '0'; while (ch!= EOF) { ch = fgetc(Rfile); if(ch=='{') count++; if (ch=='}') count--; } if ( 5 == count ) printf("\n花括号成对出现!"); else if (count > 5) printf("\n正或括号比反或括号多了 %d\n***************************************", count - 5); else printf("\n反花括号比正花括号多了 %d\n***************************************",5 - count); } return 0; }
相关文章推荐
- Morris二叉树遍历算法
- ASP.NET MVC 中出现的 方法 中的 this 关键字 用法 (this HtmlHelper helper)
- GRE写作必备句型
- iOS获取定位的方式(百度和系统自带的定位方式)
- 断点调试知多少
- Android中Listview(八)--下拉刷新ListView
- Android启动模式图文详解
- 2.1 linux文件系统应用实例:递归遍历目录
- 【Android Studio探索之路系列】之六:Android Studio添加依赖
- LeetCode "Sliding Window Maximum"
- Codeforces Round #309 (Div. 2) B. Ohana Cleans Up
- 5、iOS传值的方法-Block反向传值
- C语言函数sscanf()的用法
- What's the difference between C++ and Python
- Windows 触摸屏的 LBUTTONDOWN不单独响应,必须先有MOUSEMOVE消息,才会有LBUTTONDOWN
- 正则表达式中的逻辑运算符或(怎么用逻辑运算符或连接两个正则表达式)
- iOS开发-Day5-C的复习
- 知识储备:XML数据解析
- M - 昂贵的聘礼 - poj1062
- codeforces 553 D Nudist Beach