// ReadFile.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include "pch.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
using namespace std;
//去除字符串两边的空格,s为待处理字符串,b为从首位往后需要删除的字符,e为从末位往前需要删除的字符
void strip(string &s, char b, char e)
{
int l_index = 0;
int r_index = s.length();
for (string::iterator it = s.begin(); it != s.end(); it++)
{
if (*it == b)
{
l_index++;
}
else
{
break;
}
}
for (string::reverse_iterator rit = s.rbegin(); rit != s.rend(); rit++)
{
if (*rit == e)
{
r_index--;
}
else
{
break;
}
}
s.erase(r_index, s.length() - r_index);
s.erase(0, l_index);
}
void strip(string &s)
{
int l_index = 0;
C++:strip函数以及读取ini配置文件
最新推荐文章于 2025-02-14 00:15:00 发布