As there several ways to exchange data in the form of strings over sockets, such as:
-
using functions like:
sprintf()andsscanf()snprintf()andsscanf()printf()andstrtof()
-
or converting to char and then passing it as an array
I would appreciate if you could suggest which way and why it is efficient and better than others, or if there is another way not mentioned above. At the moment I am using the simplest way, I mean sprintf() and sscanf() functions. But I read on the web that e.g. using snprintf() function is more safe.
in C++ you can also use StringStream
you can then extract the string with
ss.str().c_str()ss.str().c_str()will result in the case above with“
“