Код: Выделить всё
0. ----.----1----.----2----.----3----.----4
1. |Hello1
2. | Hello2
3. | Hello3
4. |Hello4 Hello5
5. | Hello6
6. | Hello7 Hello8
Это мой код:
Код: Выделить всё
#include
#include
#include
using namespace std;
int main(int argc, char const *argv[])
{
bool valid;
int index = 0;
int indent = 0;
string line;
ifstream file(argv[1]);
while (getline(file, line))
{
valid = true;
while (true)
{
if (index >= line.length())
{
break;
}
if (valid && line[index] == ' ')
{
indent++;
}
else if (valid && line[index] == '\t')
{
indent += 4;
}
else if (line[index] == 'H') //example for other characters
{
// do something with character
valid = false;
}
index++;
}
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79036606/how-can-i-know-how-many-space-is-in-one-tab-character-in-a-text-file[/url]