# 第二次作业yby **Repository Path**: yu-boyang1/second-assignment-yby ## Basic Information - **Project Name**: 第二次作业yby - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-05 - **Last Updated**: 2023-11-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 第二次作业yby使用说明 输入软件名称wc.exe 输入指令1、2、3、4(1——字符数;2——单词数;3——句子数;4——行数) 输入需要调用与程序同目录下的txt文件名 注意:输入指令错误会提示“输入指令错误” 注意:文件名输错或不存在文件会提示“can not open file” e.g. wc.exe 1 test.txt 文件架构 test.jpg为运行时相关操作的截图 test.txt为软件测试所用文本文件 v0.1.cpp为空项目 v0.2.cpp为完成基础功能源代码(字符数,单词数,句子数) v0.3.cpp为完成扩展功能源代码(字符数,单词数,句子数,行数) 运行示例 long sentence(string file){//被.和;隔开的算句子 char c; long number=0; int temp=0; ifstream infile; infile.open(file.data());//将文件流对象与文件连接起来 assert(infile.is_open());//若失败,则输出错误消息,并终止程序运行 assert(infile.is_open());//若失败,将输出错误消息,并终止程序运行 infile >> noskipws; while (!infile.eof()) { infile>>c; if(65<=c&&c<=122&&temp==0){ temp++; } if(temp!=0&&c==59){ number++; temp=0; } if(temp!=0&&c==46){ number++; temp=0; } } } if(temp!=0) number++; infile.close();//关闭文件输入流 ![输入图片说明](v0.2/11.PNG)![输入图片说明](v0.3/22.PNG) ![输入图片说明](v0.3/test.jpg)