|
copying a string
|
|
06-03-2010, 05:31 AM
Post: #11
|
|||
|
|||
RE: copying a string
(06-03-2010 04:28 AM)BlueMelon Wrote: Well, it adds every line over and over again because of the So... Even if i do the NULL to the string after it's been added, it's still going to do that? No work around for it? Is there an example i can look at when doing an array and pulling data from it to strncat to a string that i can clear it and start from the top, down again? Please let me know. Thank you. Regards, ./x86 |
|||
|
01-06-2011, 02:56 PM
(This post was last modified: 01-06-2011 02:59 PM by Xupicor.)
Post: #12
|
|||
|
|||
|
RE: copying a string
Why would you even need strncpy() or strcat() if you could be working with std::string?
Code: using std::string;Oh, and instead of using plain array, why not use a std::vector<std::string> (a vector of strings)? |
|||
|
01-07-2011, 03:44 AM
Post: #13
|
|||
|
|||
|
RE: copying a string
It depends if you are using C or C++. In C++ std::string or even string library <string> can be used.
But in C you need either to write functions from scratch or to use <cstring> library or any other. There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
01-07-2011, 04:11 AM
Post: #14
|
|||
|
|||
|
RE: copying a string
True, but since the OP used string in original paste, I thought it is about C++. Yet another point why separating C and C++ forums would clear some things up.
![]() Also, you should be aware that <string> is a header file that std::string is defined in.
|
|||
|
01-07-2011, 04:18 AM
Post: #15
|
|||
|
|||
|
RE: copying a string
Yeah definitely, std::string is defined in <string>.
And C/C++ forum is the most popular, and Pascal and Delphi don't have as much threads together as C/C++. We are going to discuss that definitely. That happened because in the beginning most users of this forum were Pascal/Delphi programmers and we wanted to separate that, to have a clear line between those two languages. Not much users were using C or C++, so we had a general "C-based languages" forum which was splitted when it had grown. There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
« Next Oldest | Next Newest »
|






