User forums > Help

Error trying to run append code

(1/1)

TryingToLearn:
Why does CB throw errors (no matching function for call....) when I test this code (I got it from a c++ education website)

// appending to string
#include <iostream>
#include <string>

int main ()
{
  std::string str;
  std::string str2="Writing ";
  std::string str3="print 10 and then 5 more";

  // used in the same order as described above:
  str.append(str2);                       // "Writing "
  str.append(str3,6,3);                   // "10 "
  str.append("dots are cool",5);          // "dots "
  str.append("here: ");                   // "here: "
  str.append(10u,'.');                    // ".........."
  str.append(str3.begin()+8,str3.end());  // " and then 5 more"
  str.append<int>(5,0x2E);                // "....."

  std::cout << str << '\n';
  return 0;
}

BlueHazzard:
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

TryingToLearn:

--- Quote from: BlueHazzard on September 30, 2019, 08:06:07 pm ---http://wiki.codeblocks.org/index.php/FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

--- End quote ---
I will know for next time, thanks. For now this issue has been resolved, I must have messed something up as now it works.

Navigation

[0] Message Index

Go to full version