A
A
Alexey Mairin2017-02-18 22:38:03
C++ / C#
Alexey Mairin, 2017-02-18 22:38:03

How to parse a text document in C (Not C++)?

Good evening)
Tell me what technologies, or what to read about parsing a text file?
The bottom line is that I take some page with data, copy the source code and pull out the necessary information.
Essentially working with files?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Roman Mirilaczvili, 2017-02-18
@2ord

Text files can vary greatly:
They do not have a single approach to parsing.

N
nirvimel, 2017-02-18
@nirvimel

If it's not HTML/XML/JSON or another format for which special parsers exist, then only regular expressions remain, such as .

A
abcd0x00, 2017-02-20
@abcd0x00

Tell me what technologies, or what to read about parsing a text file?

wiki. Automated Programming
In C, you simply open a file (fopen() + fclose()), read it line by line (fgets()) or character by character (getc()), and feed the data into a state machine for analysis. When you need to work with strings, you use different functions from string.h.
This is a general approach, but there are also ready-made libraries for working with specific formats. But when there are no libraries or it is impossible to install them, then you have to write everything yourself, and you yourself will write through the state machine, because libraries are usually written through it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question