L
Leslaw Bieniasz
Hi,
What is actually the type of elements of std::string?
I am trying to read the elements from a stream, in the following
way:
std::string str = "";
int c;
// Read string size
int n;
is >> n;
// Read string
for(int i=0; i<n; i++)
{
c = is.get();
str += c;
}
This seems to work, but the compiler (C++ Builder 6.0)
issues a warning at
c = is.get();
The warning is: Conversion may lose significant digits
On the other hand, if I switch to "char" instead of "int"
it seems that the code does not work.
How to write the code that does exactly the same thing
but without the warning?
Leslaw
What is actually the type of elements of std::string?
I am trying to read the elements from a stream, in the following
way:
std::string str = "";
int c;
// Read string size
int n;
is >> n;
// Read string
for(int i=0; i<n; i++)
{
c = is.get();
str += c;
}
This seems to work, but the compiler (C++ Builder 6.0)
issues a warning at
c = is.get();
The warning is: Conversion may lose significant digits
On the other hand, if I switch to "char" instead of "int"
it seems that the code does not work.
How to write the code that does exactly the same thing
but without the warning?
Leslaw