找到数据的长度,没有。性格,没有。来自C ++中使用类的文件的数值 [英] Finding the lenght of data, no. Of character, no. Of numerical value from file using class in C++

查看:41
本文介绍了找到数据的长度,没有。性格,没有。来自C ++中使用类的文件的数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建2个类

1.找到数据的长度,没有。性格,没有。来自文件的数值

2.以上所有内容均以您自己班级的对象完成



我尝试过:



请解决此问题。我们如何在课堂上使用文件?

创建2类

Creating 2 Class
1.Find the lenght of data, no. of character, no. of numerical value from file
2.All the above is done with object of your own class

What I have tried:

please solve this. how we use file in class?
create 2 class

推荐答案

我们不做你的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是你觉得这很困难 - 这并不复杂,你需要练习。



如果你遇到一个具体的问题,那么请问一下这个问题我们会尽力帮助。但是我们不打算为你做这一切!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think - this isn't complicated, and you do need the practice.

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


你创建了一个可以读取文件的类,并提供了获取所需数据的方法。使用其中一种文件访问方法,如C ++ istream ,C fopen / fread 或C 打开 / 读取以打开并读取该文件。在阅读(例如逐行文本文件)时,处理(解析)内容以获得/计数感兴趣的数据。如何做到这一点取决于文件类型(我假设文本文件)和存储在文件中的数据。



对于文本文件,您必须识别数字值。在大多数情况下,将内容(通常是直线)拆分为单词(由空格分隔)并检查单词是否为数字应该足够了。但是你的作业太模糊了,不能更精确。



对于非文本文件,你必须知道文件的确切格式。
You create a class that can read a file and provides methods to get the desired data. Use one of the file access methods like C++ istream, C fopen / fread or C open / read to open and read the file. Upon reading (e.g. line by line with text files) process (parse) the content to get / count the data of interest. How to do that depends on the file type (I assume text files) and the data stored in the file.

For text files, you have to identify numerival values. In most cases it should be sufficient to split the content (usually line wise) into words (separated by white spaces) and check if a word is a number. But your assignment is too vague to be more precise.

For non-text files you have to know the exact format of the file.


这篇关于找到数据的长度,没有。性格,没有。来自C ++中使用类的文件的数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆