How to add N number of trailing characters to a C char array or C++ String object
Posted on 2012-09-04
I have a char array (C) or a String object (C++)
char myStr1 = "" // buffer holds 32 chars plus null terminator
String myStr2 = ""; myStr2.reserve(33); // buffer holds 32 chars plus null terminator
assign some text to the string:
myStr1 = "ABCD";
myStr2 = "ABCD";
now I want to add trailing spaces (or the character Q) to both strings to fill up to to the max chars supported by the arrays (32)
32-4 = 28
want myStr1 = "ABCDQQQQQQQQQQQQQQQQQQQQQQQQQQQQ"
this should fill myStr1 with 32 chars and leave room for the null terminator
In Oracle plsql I do this by
How to do this in C or C++ ? Must I use a for loop?