I have a back end code running in c++. I am writing a front end code in nodejs. On opening a TCP connection with server I get a struct from it which is in this format:
struct Details {
char short_name_[16];
char name_[32];
}
I am able to receive it on front end. But I want to split it back to two strings.
I tried to randomly assign short_name_ to "aaaaaaaaaaaaaaa" and similarly name_ with all 'b's. When I print data on front end
console.log('DATA ' + client.remoteAddress + ': ' + data);
output is
DATA 127.0.0.1: aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
I want to separate them back in two variables. Since char is 1 byte, I tried to convert them to a string object and tried splitting but it did not work as JSON.stringify is converting this to string to like an array with 16 97s and 32 98s. [97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98]
Also how should I do this if there integers(4 bytes) in received structs?