Get the App
SLTechnology News&Howtos  ›  Development  › 

How does C++ add the third line and the fourth number in all the txt in a directory?

Shulou Source: shulou.com Published: 2022-06-01 01:38:32 11月13日 Update

This article mainly explains the "C++ how to add all the txt under a directory in the third line of the fourth number", the article explains the content is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how C++ add all the txt in the third line of the fourth number" it!

The code is as follows:

@ echo off

:: add the third line and the fourth number in all the txt under a directory

::

Set num=0

Setlocal enabledelayedexpansion

In fact, using skip=2 to skip the first two lines is more efficient.

For% I in (* .txt) do (

Set file=%%i

For / f "tokens=1* delims=:" j in ('findstr / n.! fileholders') Do (

Set var=%%k

If% j equ 3 (set numbness, var set!) & & set / a numb num, num!

)

)

The result of echo addition is% num%

Pause

Goto: eof

@ echo off

:: add the numbers in the tenth row and the third column in all the txt files in a directory

:: code by jm 2006-9-9 CMD@XP

Setlocal enabledelayedexpansion

For% I in (* .txt) do (

Set file=%%i

Set count=0

For / f "skip=9 tokens=3" j in (! file!) Do (

Set / a count+=1

If! count! Equ 1 set / a sum+=%%j

)

)

The result of echo addition is% sum%

Pause

Thank you for your reading, the above is the content of "how C++ adds the third line and the fourth number in all the txt under a directory". After the study of this article, I believe you have a deeper understanding of how C++ adds the third line and the fourth number in all the txt under a directory, and the specific use still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Numbers directories three lines Clearing learning content results overshoot code that is ideas situations efficiency documents articles more knowledge knowledge points articles follow Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft NVidia Apple MariaDB