Reputation: 45
When I use cout
for very long string it does not output the entire string, only the end.
std::string test[] = {"alotof text--sdfsdfsdfsdfsdfsfsdferer----248 characters"};
std::cout << *test << std::endl;
output: er----248 characters
which is the end of the string only, most of the beginning was cut off
Upvotes: 1
Views: 181
Reputation: 643
I tested with Visual Studio 2010 C++ compiler, and code exactly as you wrote and my output was:
335
alotof text--sdfsdfsdfsddfasdfsdfasdfadfadfadfadfdfadfadfadfadfadfadfadsfasdfasdfasdfasdfa
sdfafdasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfadsfasdf
asdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfas
dfasdfasdfasdfasdfasdfasdfadsafsdffsdfsfsdferer----248 characters
Works fine for me.
Upvotes: 0
Reputation: 969
I tested with this:
#include <iostream>
int main(){
std::string test[] = {"alotof text--sdfsdfsdfsddfasdfsdfasdfadfadfadfadfdfadfadfadfadfadfadfadsfasdfasdfasdfasdfasdfafdasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfadsafsdffsdfsfsdferer----248 characters"};
std::cout << test[0].length() << std::endl;
std::cout << *test << std::endl;
}
here was my output:
336
alotof text-- sdfsdfsdfsddfasdfsdfasdfadfadfadfadfadfadfadfadfadfadfadfadsfasdfasdfasdfasdfasdfafdasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfadsafsdffsdfsfsdferer----248 characters
Doesn't seem to be anything wrong with it
Upvotes: 0
Reputation: 153820
Write the output to a file and check whether the content is in the file. I would guess that your string contains carriage return ('\r'
) characters which cause the position of the output to be moved to the front of the line, visually overwriting the characters already written on this line. All characters should, however, be visible in the file.
Upvotes: 1