"string too long" crash, c++ [closed] - c++

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 days ago.
Improve this question
im crashing on xstring with this error, can't figure out why
error:
the piece of code where its crashing on:
std::string response = f_network.request_to_server((xorstr_("a=") + crypt.rsa_enc(params.m_cUsername) + xorstr_("&b=") + crypt.rsa_enc(params.m_cPassword) + xorstr_("&c=") + crypt.rsa_enc(f_main.get_hwid()) + xorstr_("&pc=") + f_main.base64_encode(reinterpret_cast<unsigned char*>(hwid_part.data()), hwid_part.length())));
im using VS 2022, with the latest SDK
I already enabled multi-byte character set, but that didn't change anything, im desperate
this is a request to my API, where it asks for the username and password, i don't know why its crashing tho, i've tried everything i could, and it doesn't seem to work

Related

How to get available space on a network drive in c++? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I tried using std::filesystem::space(dir) but with no luck -> it cannot determine available disk space, sets it to uintmax.
auto info = std::filesystem::space("K:\\Dir");
if(info.available == static_cast<uintmax_t>(-1))
{
std::cout << "Error occurred!\n";
}
K:\Dir does indeed exist. And this snippet prints Error occurred for my drive mounted on K:.
If you want to get the free space you need to try
const std::filesystem::space_info spaceInfo = std::filesystem::space(dir);
cout << static_cast<std::intmax_t>(spaceInfo.free) << endl;
Here dir = "/path/to/dir/";
Refer cppreference

Why file is not created in /etc/ directory [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Please find the code sample
void createFile(const std::string& FileName, const std::string& Content)
{
ofstream of(FileName.c_str());
of<<Content;
of.close();
}
const std::string testFile = "/etc/testFile";
const std::string EmptyContent = "";
createFile(testFile, EmptyContent);
File is not creating at /etc/ directory. I think this is related to permissions. What extra I have to add in the code to work.
There's nothing extra that you can add to this program to "make it work". If an arbitrary program can write to /etc, this would toss the traditional POSIX security model out the window.
In order to be able to write to /etc, your program must be executed as root.
It seems to be a permission issue. Try to run your program using sudo:
sudo yourprogram

Arduino double command [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I'm trying to find a way for my Arduino to recognize some of the commands I'm attempting to send over serial (via Raspberry Pi)
I'm come as far as to detect 2 commands, but I'm stuck at my last.
To give a little bit more detail, I have my fingerprint scanner (GT-511C3) connected, and the library installed that will make it work.
That said, with the first 2 commands consist the verifying of fingerprints to ID (which works great) and the enrolling of fingerprints to new ID's (also work great) these parts of the script are triggered by the respective ASCII code "0" and "1".
My last, and problematic command "2" to remove an ID, is where I'm seeking help with.
Here's the code I'm currently working with:
if(ser == '2'){
while(val2 == 0){
char val3 = 0;
delay(10);
Serial.println("Type the ID to be deleted");
delay(2500);
fps.DeleteID(Serial.read());
val3 == Serial.read();
delay(10);
Serial.println("Deleted ID:");
Serial.print(val3);
delay(10);
val2 = 1;
}
}
I'm attempting to send the ASCII code "2" over Raspberry Pi through serial to the Arduino, followed by the ID that needs to be removed. It triggers after the command "2" is send, but refuses to read the ID and as such, I'm unable to finish it.
Any help or insight would really be appreciated.
val3 == Serial.read(); should be val3 = Serial.read();. You have an extra = which turns it into a useless comparison.

How to explain the strange output by "puts" in c++? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am reading a piece of code written by others, there is one line like this:
cout << "Data Loaded" << endl;
it seems nothing strange, however, the actually output is:
[18607330327, 18790481919] [19144201237, 19327352831] [20754813973, 20937965567] [21291684885, 21474836479] [21474836482, 21653864362] [22011707392, 22190735274] [23622320128, 23801348010] [24159191040, 24338218922] [27197264917, 27204255743] [27205653525, 27212644351] [27230819349, 27230959453] [27233615872, 27235153757] [30064771072, 30067638186] [30073159680, 30076026794] [30098325504, 30098440106] [30098456576, 30098536200] Data Loaded
where does the extra output come from? if I comment that line, then, nothing is output.
I then include the <cstdio> and replace that line by puts("Data Loaded"), still, the extra info get printed.
cout is a buffered output stream, and endl not only creates a new line, it also flushes the buffer. Without the flushing of the buffer it might happen that you do not see the output of a previous cout.

Ncurses: movement [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I have a problem with programming movement using C++ and Ncurses.
I'm programming a pacman and the main problem is, that I just want last pressed key in time period.
When I use usleep, it saves every key pressed during sleeping and then it's working with that in the order.
Thanks for ideas.
What did you try?
Something like this should work, if I understood correctly what you try to achieve:
int t = your_delay;
while (t --> 0)
{
sleep(1);
c = getch();
}
If you really need to time it down to the microsecond, this might not be the best approach, but if you can have some tolerance, this should be enough.
Are you in no-delay mode? If so, this might work:
usleep(your_delay);
last_key = ERR;
while ( (key=getch()) != ERR ) {
last_key = key;
}
// "last_key" now holds most recent key, if there was one, else ERR