C: How to get the number of information in the txt file?

Updated on technology 2024-02-08
11 answers
  1. Anonymous users2024-02-05

    textreader reader;

    int linecount = 0;

    Method 1: while( = null) )length;

    I haven't tested it, method 1 should be fine, method 2 can be imprecise, there is an error of 1.

    Method 1 is to read each line honestly.

    The idea of method 2, 3, and 4 is to count the number of occurrences of line breaks (), which is not very accurate. Because line breaks do vary from system to system. And your file is required to be very regular, and no blank lines are allowed.

  2. Anonymous users2024-02-04

    You can define a variable int linecont=0; while (read by line until end)."Shared"+"OK");It's been a long time since I've written a program, I hope it helps you This answer is made by.

    Courtesy.

  3. Anonymous users2024-02-03

    Damn, your method is really complicated, use mine! You can just copy the past call, and filepath refers to the file path public int getrows(string filepath)}

  4. Anonymous users2024-02-02

    You should first see what format this txt is, I think this format is likely to be the format of csv, after determining the format, you can use the split method to divide it into an array, and then read it, if there is really no format, you can only use keyword positioning + regular expressions to achieve.

  5. Anonymous users2024-02-01

    Instantiate a fileinfo object with a filepath, and the length property is the size (in bytes).

    As for how many pieces of data, I don't understand what you want to say, if it's to check the number of rows in txt, use using (streamreader sr = fileinfo object. opentext())

    It should be fine.

  6. Anonymous users2024-01-31

    file class has, you can check it, and if you can't find it, look for me.

  7. Anonymous users2024-01-30

    Isn't this an ini config file?

    using system;

    using ;

    using ;

    using ;

    using ;

    namespace ini

    Read the ini file.

    Node name.

    Keywords.

    ini file path.

    Value. static public string inireadvalue(string section, string key, string filepath)}}

  8. Anonymous users2024-01-29

    The format of your deposit is too messy, and it's so convenient to add start and end tags.

  9. Anonymous users2024-01-28

    It is recommended to learn XML, which is the best for information saving.

  10. Anonymous users2024-01-27

    Refer to the operation of the ini file.

  11. Anonymous users2024-01-26

    I remember there were functions that read line by line, put them in an array of string str, and then go to the array and look for the contain element.

Related questions
11 answers2024-02-08

In C++, vector is used as a container, and its function is to store variables of struct type. Here's how vector might be used: >>>More

6 answers2024-02-08

After selecting the files to be recovered, the system will jump to this interface, asking you to select a logical drive to save the recovered files, here you must note that the selected drive must have enough remaining space, at least larger than the total amount of data to be recovered, this is very important, otherwise there will be data recovery failure. When choosing a drive, it is best to create a new folder, for example, if you want to restore to the X drive, it is best not to directly select the X disk in the target drive, so that the recovered scattered files will be directly copied to the root directory of the X drive, and it will be very troublesome to find the recovered data, so it is recommended to create a new folder named "shujuhuifu" in the X disk, and then point the recovery target to it, and it will be easier to look it up at that time. After selecting the recovery destination drive, we click Next, then make a cup of coffee and wait patiently for the recovery of the dataAfter a short system scan, the software will load all the disk letters inserted into the computer, select the partition you need to recover on the left, and click Next to start scanning the drive that needs to be recovered. >>>More

3 answers2024-02-08

The file class is used for typical operations such as copying, moving, renaming, creating, opening, deleting, and appending to files. You can also use the file class to get and set file properties or datetime information about file creation, access, and write operations. >>>More

14 answers2024-02-08

In the tool Folder Options view, there is an option to show hidden files. Right there, you can hide your files. It's very simple. Ha ha.

8 answers2024-02-08

It's not that there's no way, it's that it depends on how high your level is! >>>More