亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

程序運行到這里的時候出現故障 但是并非是調試出錯 而是運行之后程序不能繼續運行有點像“無響應”

程序運行到這里的時候出現故障 但是并非是調試出錯 而是運行之后程序不能繼續運行有點像“無響應”

C++
莫回無 2023-04-20 19:15:07
請問一下這個函數的具體用法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是字符串常量,
查看完整描述

2 回答

?
收到一只叮咚

TA貢獻1821條經驗 獲得超5個贊

string的成員函數insert有以下多種重載:

string &insert(int p0, const char *s);——在p0位置插入字符串s

string &insert(int p0, const char *s, int n);——在p0位置插入字符串s的前n個字符

string &insert(int p0,const string &s);——在p0位置插入字符串s

string &insert(int p0,const string &s, int pos, int n);——在p0位置插入字符串s從pos開始的連續n個字符

string &insert(int p0, int n, char c);//在p0處插入n個字符c

iterator 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 "stdafx.h"//If the vc++6.0, with this line.#include <string>#include <iostream>using namespace std;//int main(void){    string a="1234567890",b="abcdefghijklmn";    a.insert(3,b,5,4);    cout << a << endl;    return 0;}

輸出是123fghi4567890.


查看完整回答
反對 回復 2023-04-23
?
泛舟湖上清波郎朗

TA貢獻1818條經驗 獲得超3個贊

string-》c風格字符串要轉換的。成員函數c_str();

查看完整回答
反對 回復 2023-04-23
  • 2 回答
  • 0 關注
  • 165 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號