|
![]() | 作者: wotus [wotus]
![]() |
登录 |
write a program to count blanks,tabs,and newlines. 谢谢! [此贴被 wotus(wotus) 在 02月29日21时06分 编辑过] |
地主 发表时间: 04-02-29 21:05 |
![]() | 回复: 286 [unique] ![]() |
登录 |
#define MAXLEN 64000 #include <stdio.h> main(int argc,char *argv[]) { int blanks=0,tabs=0,newlines=0,int i; FILE *fp; char buf[MAXLEN]={0}; fp.open(argv[1]); fp.read(buf,MAXLEN); fp.close(); for (i=0;i<MAXLEN;i++) { if (buf[i]==0x20) blanks++; if (buf[i]=='\n') newlines++; if (buf[i]=='\t') tabs++; } printf("There are %d blanks, %d tabs, %d newlines in the file %s",blanks,tabs,newlines,argv[1]); } |
B1层 发表时间: 04-03-01 12:39 |
![]() | 回复: yingzike [yingzike] ![]() |
登录 |
286: 现在每天都做题? ![]() ![]() ![]() |
B2层 发表时间: 04-03-01 13:08 |
![]() | 回复: wotus [wotus] ![]() |
登录 |
谢谢楼上的!谢谢! |
B3层 发表时间: 04-03-01 13:35 |
![]() | 回复: sniper167 [sniper167] ![]() |
登录 |
不是自己的作业吧? |
B4层 发表时间: 04-03-01 22:40 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号