相关疑难解决方法(0)

在c ++中连接stringstream

如何连接两个字符串流?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include "types.h"    

int main () {
    char dest[1020] = "you";
    char source[7] = "baby";
    stringstream a,b;
    a << source;
    b << dest;
    a << b; /*HERE NEED CONCATENATE*/
    cout << a << endl;
    cout << a.str() << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

两次尝试中的输出如下:

0xbf8cfd20
baby0xbf8cfddc
Run Code Online (Sandbox Code Playgroud)

期望的输出是babyyou.

c++ concatenation stringstream

9
推荐指数
4
解决办法
3万
查看次数

标签 统计

c++ ×1

concatenation ×1

stringstream ×1