Aug 10, 2022 at 8:35pm UTC
Hallo c-plus plus,
Is there a way, to get the letter ASCII(code:10)
to print to a string.
I will keep looking on the net, on this form.
tnx
Last edited on Aug 10, 2022 at 8:36pm UTC
Aug 10, 2022 at 8:37pm UTC
std::cout << (char )10 << '\n' ;
Aug 10, 2022 at 9:35pm UTC
Last edited on Aug 11, 2022 at 2:03pm UTC
Aug 11, 2022 at 5:26am UTC
I can't make sense of that last post, but are you trying too hard here?
string s; //empty string
s += (char)(10); //put the char 10 into a string.
cout << s;
Note that gui text boxes may require you to enable 'want multiline' or whatever the setting is called before it will work.
Aug 11, 2022 at 6:25am UTC
Line 15: sizeof (searchFora)
is wrong. Use searchFora.size()
instead.
Since both data.find(...)
and data.replace(...)
also take c-style strings you don't need to convert them to std::string.
Last edited on Aug 11, 2022 at 6:25am UTC
Aug 11, 2022 at 8:46am UTC
If you're trying to do a multiple-replace by replacing all occurrences of one string with another, then possibly:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#include <fstream>
#include <iostream>
#include <string>
#include <iterator>
#include <string_view>
void replace_all(std::string& str, std::string_view fnd, std::string_view rep) {
for (size_t found {}; (found = str.find(fnd, found)) != std::string::npos; found += rep.size())
str.replace(found, fnd.size(), rep);
}
int main() {
if (std::ifstream ifs { "Text.txt" }) {
std::string data((std::istreambuf_iterator<char >(ifs)), std::istreambuf_iterator<char >());
replace_all(data, "(crc_code_10)" , "\n" );
// use data here
std::cout << data << '\n' ;
} else
std::cout << "Cannot open file\n" ;
}
Last edited on Aug 11, 2022 at 9:04am UTC
Aug 15, 2022 at 10:35am UTC
He its fix's
but the problem is not was not in the reading of the file but in the CreateWindow.
that I forgot CreateWindow(ES_MULTILINE)
tnx for the assistance.
Aug 15, 2022 at 1:15pm UTC
Glad you found that... I was trying to say as much, but I assumed you were using a WYSIWYG where its an option to click on your window or widget properties rather than doing it in code.