Jump to content
  • Advertisement
Sign in to follow this  
OpenGL_Guru

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

This topic is 4869 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
Advertisement
Is there any chance endl is something else? You should be using std::endl.

Share this post


Link to post
Share on other sites
This is strange indead. You dont have to include <string> but <iostream>. Are you using namespace std ?? Make sure endl is not declared as a pointer of some kind or variable.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!