Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9155555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:37:03+00:00 2026-06-17T12:37:03+00:00

I am rusty with C++ and have been using python/php too much recently which

  • 0

I am rusty with C++ and have been using python/php too much recently which makes everything too easy haha. I’m having a memory corruption when I was trying to do this:

// values is passed to the function as std::string &values
// and values is declared earlier as std::string values = "";
values += std::string("\n")

Ideally I want to actually do this in the end, but was just doing the std::string stuff piece by piece since I seem to be running into errors:

// data is an int array
values += std::string("\n") + data[l] + " " + data[j-1];

How can i concatenate chars, ints, and std::strings together again? Thanks

P.S. This was the gdb stack i got when trying to just do “\n” above:

34                                      values += std::string("\n");// + data[l] + " " + data[j-1];
(gdb)
*** glibc detected *** /{HIDDEN}/main: malloc(): memory corruption (fast): 0x0000000000603030 ***
======= Backtrace: =========
/lib64/libc.so.6[0x38ec07b776]
/lib64/libc.so.6[0x38ec07e107]
/lib64/libc.so.6(__libc_malloc+0x63)[0x38ec07f443]
/lib64/libstdc++.so.6(_Znwm+0x1d)[0x38eec5f59d]
/lib64/libstdc++.so.6(_ZNSs4_Rep9_S_createEmmRKSaIcE+0x59)[0x38eecbc339]
/lib64/libstdc++.so.6(_ZNSs12_S_constructIPKcEEPcT_S3_RKSaIcESt20forward_iterator_tag+0x35)[0x38eecbdd25]
/lib64/libstdc++.so.6(_ZNSsC2EPKcRKSaIcE+0x43)[0x38eecbde03]
/{HIDDEN}/main[0x400cb6]
/{HIDDEN}/main[0x400ba7]
/{HIDDEN}/main[0x400eeb]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x38ec021a05]
/{HIDDEN}/main[0x400a29]
======= Memory map: ========
00400000-00402000 r-xp 00000000 00:23 549601814                          /{HIDDEN}/main
00601000-00602000 r--p 00001000 00:23 549601814                          /{HIDDEN}/main
00602000-00603000 rw-p 00002000 00:23 549601814                          /{HIDDEN}/main
00603000-00624000 rw-p 00000000 00:00 0                                  [heap]
38ebc00000-38ebc20000 r-xp 00000000 08:07 7604569                        /usr/lib64/ld-2.16.so
38ebe20000-38ebe21000 r--p 00020000 08:07 7604569                        /usr/lib64/ld-2.16.so
38ebe21000-38ebe22000 rw-p 00021000 08:07 7604569                        /usr/lib64/ld-2.16.so
38ebe22000-38ebe23000 rw-p 00000000 00:00 0
38ec000000-38ec1ad000 r-xp 00000000 08:07 7604570                        /usr/lib64/libc-2.16.so
38ec1ad000-38ec3ad000 ---p 001ad000 08:07 7604570                        /usr/lib64/libc-2.16.so
38ec3ad000-38ec3b1000 r--p 001ad000 08:07 7604570                        /usr/lib64/libc-2.16.so
38ec3b1000-38ec3b3000 rw-p 001b1000 08:07 7604570                        /usr/lib64/libc-2.16.so
38ec3b3000-38ec3b8000 rw-p 00000000 00:00 0
38ed000000-38ed100000 r-xp 00000000 08:07 7604585                        /usr/lib64/libm-2.16.so
38ed100000-38ed2ff000 ---p 00100000 08:07 7604585                        /usr/lib64/libm-2.16.so
38ed2ff000-38ed300000 r--p 000ff000 08:07 7604585                        /usr/lib64/libm-2.16.so
38ed300000-38ed301000 rw-p 00100000 08:07 7604585                        /usr/lib64/libm-2.16.so
38ed800000-38ed815000 r-xp 00000000 08:07 7604600                        /usr/lib64/libgcc_s-4.7.2-20121109.so.1
38ed815000-38eda14000 ---p 00015000 08:07 7604600                        /usr/lib64/libgcc_s-4.7.2-20121109.so.1
38eda14000-38eda15000 r--p 00014000 08:07 7604600                        /usr/lib64/libgcc_s-4.7.2-20121109.so.1
38eda15000-38eda16000 rw-p 00015000 08:07 7604600                        /usr/lib64/libgcc_s-4.7.2-20121109.so.1
38eec00000-38eece5000 r-xp 00000000 08:07 7604613                        /usr/lib64/libstdc++.so.6.0.17
38eece5000-38eeee4000 ---p 000e5000 08:07 7604613                        /usr/lib64/libstdc++.so.6.0.17
38eeee4000-38eeeec000 r--p 000e4000 08:07 7604613                        /usr/lib64/libstdc++.so.6.0.17
38eeeec000-38eeeee000 rw-p 000ec000 08:07 7604613                        /usr/lib64/libstdc++.so.6.0.17
38eeeee000-38eef03000 rw-p 00000000 00:00 0
7ffff7fd6000-7ffff7fdb000 rw-p 00000000 00:00 0
7ffff7ffc000-7ffff7ffe000 rw-p 00000000 00:00 0
7ffff7ffe000-7ffff7fff000 r-xp 00000000 00:00 0                          [vdso]
7ffffffde000-7ffffffff000 rw-p 00000000 00:00 0                          [stack]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:37:04+00:00Added an answer on June 17, 2026 at 12:37 pm

    You can use std::stringstream to combine string, int, and chars as follows:

    #include<iostream>
    #include<sstream>
    
    void main()
    {
    
        std::stringstream ss;
    
        int x = 5;
        std::string y = "Hello";
        char z = 'z';
    
        ss<<x<<y<<z;
    
        std::string result = ss.str();
    
        std::cout<<result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have experience in C++ but have recently been using python exclusively at work,
Perhaps I am getting rusty (have been writing in Python recently). Why does this
It has been a while since I have programmed PHP so I am very
I use a cluster of about 30 machines that have all recently been reconfigured
I have been getting back into C++ lately. I've been away from C++/CLI using
For almost as long as I've been using vim and have known enough C,
Here's an easy one but my web fu is rusty. I have a a
I'm rusty a bit here. I have a vector (camDirectionX, camDirectionY, camDirectionZ) that represents
I'm a bit rusty on my regexp and Javascript. I have the following string
I'm rusty in SQL and completely new to SQL Alchemy , but have an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.