|
-
June 22nd, 2010, 01:38 PM
#1
[RESOLVED] std string question
im not really familiar with the string class and i came across a "problem" on my code
how is it possible to copy an array of bytes (binary) from a char array to a string variable?
the char array holds the data of a file , when i try to copy to a string it only copies until the first null byte
-
June 22nd, 2010, 01:42 PM
#2
Re: std string question
Code:
string s;
char buffer[256]; // whatever
s.assign(buffer,n); // n = number of bytes to copy
-
June 22nd, 2010, 01:44 PM
#3
Re: std string question
thank you Philip Nicoletti!
-
June 22nd, 2010, 10:00 PM
#4
Re: std string question
 Originally Posted by Cpp_Noob
thank you Philip Nicoletti!
If you want to construct a string like this:
Code:
char buffer[1000];
//...
std::string s(buffer, 1000);
Regards,
Paul McKenzie
-
June 23rd, 2010, 09:27 AM
#5
Re: [RESOLVED] std string question
thanks, im still new to the string class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|