| charlie (41) | |||
|
Hello,I was Designing a Program that has two function the random_ip() and main() the random_ip() returns an array of random generated ip address
it seems the code has a problem with the memcpy() function.Please Help figure this one out! Thanks. | |||
|
|
|||
| kbw (4346) | |
|
That code shouldn't compile. If you're going to determine BUFSIZE at runtime, you have to dynamically allocate memory. The whole things' a bit of a mess. I'd say the memcpy is the least of your problems. You know that code is asking for trouble, right? | |
|
|
|
| Galik (2228) | |
|
There is quite a lot of dangerous code there! ;o) I would take a look at using std::string instead of your char*s and std::vector instead of your arrays. Also you could look at using C++ streams rather than the old, C printf() functions:strings http://cplusplus.com/reference/string/string/ vectors http://cplusplus.com/reference/stl/vector/ streams http://cplusplus.com/doc/tutorial/basic_io/ | |
|
|
|
| PanGalactic (1571) | |
| There is a very distinct difference between writing C++ code and writing C code. While C++ does provide backwards compatibility with C, the languages are remarkably different from one another. This is clearly C code. It almost seems off-topic for this site. | |
|
|
|