T
T
tj572017-04-06 15:31:57
Programming
tj57, 2017-04-06 15:31:57

How to read individual parts of a text file in C++?

There is a text file of this kind (only there are much more lines):
XOeSnsGOvxc.jpg
How to read individual columns from this file? (specifically - 2,3 and 10)

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Saboteur, 2017-04-06
@saboteur_kiev

Read line by line, parse the line, take the required columns and work with them. No other way.

V
Vladimir Vladimirovich, 2017-04-06
@leha2148

most likely you need to parse this tex. You read it line by line and as soon as you meet a space in the line, you throw a read piece (from the previous space) into a separate array. And so with all the lines. As a result, you will get a certain number of arrays, each of which will be a column from your text. As an option

A
asd111, 2017-04-06
@asd111

The easiest option.

while (std::getline (file,line)){
    //Для VC++ sscanf_s
    sscanf(line.c_str(),"%*s %x %x %*x %*x %*x %*x %*x %*x %x", &stolbec_2,&stolbec_3,&stolbec_10);    
}

D
dummyman, 2017-04-06
@dummyman

I don’t know about you, but I would use awk for such purposes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question