Re: Would this be safe?
Date: Wed, 30 Mar 2005 01:51:42 GMT
> I am new to the C++ world, after spending many years as a C programmer.
> I am attempting to convert a std::string to a array of characters (C
> string), to enable me to send the data via a socket.
s.c_str(). The result pointer is valid as long as s isn't changed.
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
Q: What is the most annoying thing on usenet and in e-mail?
- Re: sending data, no strings via socket
... IIRC, #writeis converting arg to a string, so the number 10 is converted to the string "10", as you noticed. ... If you want a friendly interface to do this, check out my bit-struct lib: ... Also note that the pointer is replaced with the buf bytes themselves, which is probably how you want it (you didn't really want to send a pointer over a tcp socket, right?). ...
- Re: Efficency and the standard library
... loop will dereference a null pointer if argument strInstring is ... this code, out of adversarial hatred, envy and malice. ... Some C programmers in these threads would suggest const ... the output string. ...
- Re: ptrdiff_t overflow/underflow
... satisfy the vast majority of trim() use cases. ... It may point to a valid string, ... If any pointer can be converted to a 'void *', assuming there isn't any meta-data outside of the pointer's object representation, and assuming an implementation must not allow two 'void *' values to represent two separate objects, it seems like a fair upper bound. ... And if a pointer value includes bounds information, perhaps the implementation would be kind enough to document either the representation or how to access the information. ...
- Re: strtok ( ) help
... > splitCommandssomehow modifying the pointer, but I HAVE to call that ... Here's an idea of how to use the strtok() function. ... don't mind trashing the contents of a string s, ... will give you a loop that extracts the tokens one at a time from s. ...
- Re: "Mastering C Pointers"....
... A pointer is a kind of variable that can "point to" some object. ... has a type (pointer to int), and a value of some kind. ... You may know that you can access these integers by using array notation ... The function will take one argument, a string, and will return the length ...