Learning C++/lua - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Off Topic (https://forum.cuberite.org/forum-9.html) +--- Forum: Off Topic Discussion (https://forum.cuberite.org/forum-10.html) +--- Thread: Learning C++/lua (/thread-641.html) |
Learning C++/lua - NiLSPACE - 12-04-2012 Does anyone know why this code: Quote:#include <iostream>doesn't work? i get an error in the cout << "IT WORKS!\n"; cout << "\nPress Enter to continue" << endl; RE: Learning C++ - FakeTruth - 12-04-2012 use std::cout instead of just cout Also, next time you get an error, be sure to post the actual error message RE: Learning C++ - NiLSPACE - 12-04-2012 thank you its weard because the book says "cout" not "std::cout" :O RE: Learning C++ - FakeTruth - 12-04-2012 maybe somewhere they have a Code: using namespace std; RE: Learning C++ - xoft - 12-05-2012 In older C++, cout used to be global, you could use it without the std prefix. But that was years ago, and only in some compilers. RE: Learning C++ - NiLSPACE - 12-10-2012 thanks, i'm now trying to make a configuration file just like with my build script but than in c++ just to practise. i'm now struggeling that i can't put letters in a variable. with the server description part if i now put letters in it, it says 0 in the settings.ini. if you want to look in the "source" this is it: Code: #include <iostream> RE: Learning C++ - FakeTruth - 12-10-2012 try using Code: string Description; ? RE: Learning C++ - NiLSPACE - 12-10-2012 it works but i can only have one word. if i type in: New Description it only shows New RE: Learning C++ - xoft - 12-10-2012 I suppose that cin operator >> extract only until any whitespace. The solution would be to repeat reading from cin until you get a '\n', and concatenate everything you've read into a string. I never particularly liked streams, so I've never actually learnt much about them. Seems there's a std::getline() just for this purpose: http://www.cplusplus.com/reference/string/getline/ RE: Learning C++ - NiLSPACE - 12-11-2012 yay thanks it works i can now get things like this: Quote:[Server] |