Sign in to follow this  

std::cout endl = weird results....

This topic is 4529 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi all i had a problem last week with regarding printing out a string and some other stuff and getting weird results. i thought my string allocation maybe was being messed up but through trial and error i realized it was the endl that i was giving my problems. i have never had this happen before so i hope you could possibly help me out... whenever i invoke the endl such as a simple line of code: std::cout << endl; my output is: 004010EB wha????????? i am including <string> btw and like i said i havenever had this happen before. thanks for your time in advance :)

Share this post


Link to post
Share on other sites
nevermind i figured it out..why is it when i post on here half the time about 5 minutes later i figure it out while spending more than enough time before ive written the post?

anyway i have multiple classes together and inheritance going on. even though i included the <string> header file and the <iostream> header file in the .cpp file i didnt do the following line of code:

using namespace std;

even though i had done it with parent class it still was giving me this garbage in the child class.

ok ive got it fixed but why was i getting this output? just wanna know deeper of the problem.. thanks!

Share this post


Link to post
Share on other sites
well i was including <iostream> and <string> because of strcpy() that i needed.. but as i just wrote (as you were writing :D) i explained the problem but would like to know further why i was getting the output because of the line of code i didnt implement... thanks again.

Share this post


Link to post
Share on other sites
Most likely the endl was resolving to a symbol other than std::endl that had an implicit conversion to void *. If you use operator<< on a std::ostream with a void *, it prints the address of the pointer.

Share this post


Link to post
Share on other sites
thanks mod.. like i said this has never happpened before and i have an unusual multiple inheritance going on such as

class a : protected class b, private class c
{...}

i simply forgot to add the using namespace std in one of my .cpp files ...so i guess i wont ever forget that again.. or at least when i get that error i will know what i need to change...

Share this post


Link to post
Share on other sites

This topic is 4529 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this