程序运行到这里的时候出现故障 但是并非是调试出错 而是运行之后程序不能继续运行有点像“无响应”

请问一下这个函数的具体用法
void set_about(string about)
{
for(int i = 0;i < (int)(about.length() / 2) / 30 && i < 25;i++)
for(int j = 0;j <= 29;j++)
{
if(about.substr(i * 30 * 2 + j * 2,2) == LINEFEED)
about.insert(i * 30 * 2 + j * 2,BLANK,0,2);
set_pixel(i + 8,j + 8,about.substr(i * 30 * 2 + j * 2,2));
}
for(int i = 0;i < (about.length() / 2) % 30;i++)
set_pixel((int)(about.length() / 2) / 30 + 8,i + 8,about.substr((int)((about.length() / 2) / 30) * 30 * 2 + i * 2,2));
}
以上是我所写的一个函数,其中set_pixel()是用于打点的,在此之前此函数并未出现故障 而LINEFEED 和 BLANK是字符串常量,

莫回无
浏览 88回答 2
2回答

收到一只叮咚

string的成员函数insert有以下多种重载:string &insert(int p0, const char *s);——在p0位置插入字符串sstring &insert(int p0, const char *s, int n);——在p0位置插入字符串s的前n个字符string &insert(int p0,const string &s);——在p0位置插入字符串sstring &insert(int p0,const string &s, int pos, int n);——在p0位置插入字符串s从pos开始的连续n个字符string &insert(int p0, int n, char c);//在p0处插入n个字符citerator insert(iterator it, char c);//在it处插入字符c,返回插入后迭代器的位置void insert(iterator it, const_iterator first, const_iteratorlast);//在it处插入从first开始至last-1的所有字符void insert(iterator it, int n, char c);//在it处插入n个字符c以下是第二行性能的举例代码://#include&nbsp;"stdafx.h"//If&nbsp;the&nbsp;vc++6.0,&nbsp;with&nbsp;this&nbsp;line.#include&nbsp;<string>#include&nbsp;<iostream>using&nbsp;namespace&nbsp;std;//int&nbsp;main(void){&nbsp;&nbsp;&nbsp;&nbsp;string&nbsp;a="1234567890",b="abcdefghijklmn";&nbsp;&nbsp;&nbsp;&nbsp;a.insert(3,b,5,4);&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;<<&nbsp;a&nbsp;<<&nbsp;endl;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;0;}输出是123fghi4567890.

泛舟湖上清波郎朗

string-》c风格字符串要转换的。成员函数c_str();
打开App,查看更多内容
随时随地看视频慕课网APP