If I have an vector of unsigned char's, what's the best way to pass them to a function that only takes a vector of char's? What about a vector of signed chars?
In the conversion, is there any risk of losing data?
If I have an vector of unsigned char's, what's the best way to pass them to a function that only takes a vector of char's? What about a vector of signed chars?
In the conversion, is there any risk of losing data?
You have to copy the data to a vector of signed chars. There's no good way to just twiddle the type. However, there is no risk of data loss. Only the type changes -- the bit patterns remain the same.
A custom vector class could be written that allows magical conversion to and from signed or unsigned, but you can't do it with std::vector<T>
You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.
Outside of your DOS world, your header file is meaningless.
I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
Look up a
C++ Reference
and learn
How To Ask Questions The Smart Way
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
C++ Tutorial
5 ways you can learn to program faster
The 5 Most Common Problems New Programmers Face
How to set up a compiler
8 Common programming Mistakes
What is C++11?
Creating a game, from start to finish
Recent additions
How to create a shared library on Linux with GCC
- December 30, 2011
Enum classes and nullptr in C++11
- November 27, 2011
Learn about The Hash Table
- November 20, 2011
Rvalue References and Move Semantics in C++11
- November 13, 2011
C and C++ for Java Programmers
- November 5, 2011
A Gentle Introduction to C++ IO Streams
- October 10, 2011