我正在编写一个解析日志文件的程序,并决定尽可能地将其作为C ++,并且我遇到了这行的调试断言 -
<div align="center" class="page">
<div class="mainwrapper">
<div class="section-holder">
<div class="section-item">
<div class="section-image">
<img src="https://cdn.shopify.com/s/files/1/0938/8938/products/10231100205_1_1315x1800_300_CMYK_1024x1024.jpeg?v=1445623369">
</div>
<div class="section-info">
<h5>Winter Jacket</h5>
<h6>$99.99</h6>
</div>
</div>
<div class="section-item">
<div class="section-image">
<img src="https://cdn.shopify.com/s/files/1/0938/8938/products/10231100205_1_1315x1800_300_CMYK_1024x1024.jpeg?v=1445623369">
</div>
<div class="section-info">
<h5>Winter Jacket</h5>
<h6>$99.99</h6>
</div>
</div>
<div class="section-item">
<div class="section-image">
<img src="https://cdn.shopify.com/s/files/1/0938/8938/products/10231100205_1_1315x1800_300_CMYK_1024x1024.jpeg?v=1445623369">
</div>
<div class="section-info">
<h5>Winter Jacket</h5>
<h6>$99.99</h6>
</div>
</div>
<div class="section-item">
<div class="section-image">
<img src="https://cdn.shopify.com/s/files/1/0938/8938/products/10231100205_1_1315x1800_300_CMYK_1024x1024.jpeg?v=1445623369">
</div>
<div class="section-info">
<h5>Winter Jacket</h5>
<h6>$99.99</h6>
</div>
</div>
<div class="section-item">
<div class="section-image">
<img src="https://cdn.shopify.com/s/files/1/0938/8938/products/10231100205_1_1315x1800_300_CMYK_1024x1024.jpeg?v=1445623369">
</div>
<div class="section-info">
<h5>Winter Jacket</h5>
<h6>$99.99</h6>
</div>
</div>
<div class="section-item">
<div class="section-image">
<img src="https://cdn.shopify.com/s/files/1/0938/8938/products/10231100205_1_1315x1800_300_CMYK_1024x1024.jpeg?v=1445623369">
</div>
<div class="section-info">
<h5>Winter Jacket</h5>
<h6>$99.99</h6>
</div>
</div>
<div class="section-item">
<div class="section-image">
<img src="https://cdn.shopify.com/s/files/1/0938/8938/products/10231100205_1_1315x1800_300_CMYK_1024x1024.jpeg?v=1445623369">
</div>
<div class="section-info">
<h5>Winter Jacket</h5>
<h6>$99.99</h6>
</div>
</div>
<div class="section-item">
<div class="section-image">
<img src="https://cdn.shopify.com/s/files/1/0938/8938/products/10231100205_1_1315x1800_300_CMYK_1024x1024.jpeg?v=1445623369">
</div>
<div class="section-info">
<h5>Winter Jacket</h5>
<h6>$99.99</h6>
</div>
</div>
<div class="section-item">
<div class="section-image">
<img src="https://cdn.shopify.com/s/files/1/0938/8938/products/10231100205_1_1315x1800_300_CMYK_1024x1024.jpeg?v=1445623369">
</div>
<div class="section-info">
<h5>Winter Jacket</h5>
<h6>$99.99</h6>
</div>
</div>
<div class="section-item">
<div class="section-image">
<img src="https://cdn.shopify.com/s/files/1/0938/8938/products/10231100205_1_1315x1800_300_CMYK_1024x1024.jpeg?v=1445623369">
</div>
<div class="section-info">
<h5>Winter Jacket</h5>
<h6>$99.99</h6>
</div>
</div>
</div>
</div>
</div>
这似乎是因为日志文件的第2000行的值为-80的字符。
所以,我试过这个
sLine.erase(remove_if(sLine.begin(), sLine.end(), isspace), sLine.end());
但是这段代码片段没有任何解释。
所以,最后我有三个问题 -
感谢您的帮助!
答案 0 :(得分:1)
如果您只想删除空格字符,以下代码将起作用
sLine.erase(std :: remove_if(sLine.begin(),sLine.end(),[](char c){ return(c ==''); }),sLine.end());