Im sorry and im new here and haven't learned all the words around C++ programming so it was hard to search for a topic that had my answer :/
But my question is:
Im doing a little game, casting dices etc. The problem is that the program will ask for player 1 then if i enter a name and enter it will ask for player two and so going on until i just press enter with a empty field and then continue the game.
The problem is i don't have any clue what code bits to start studying and how i shall lay it up, feels like i need a new string declaration automatically for each name.
First of all you have to learn the very basics. Have you got a book or do you follow some online tutorial? If not get/find one, it will be overwhelming trying to grasp everything at once.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
I'm sorry if i formulated me wrong but i know the really really basic i think
But i received a tip above about vectors so i check that up
But a friend told me to use an array?
A vector is an array basically. It's just a lot more powerful than a simple array, but gives you the same functionality. A simple array requires you specify a size whereas a vector grows dynamically as needed, which seems more appropriate for your needs.
Your friend is probably using C most of the time so don't listen to him in this case. Listen to GCDEF instead and get used to using STL (browse around a bit at cplusplus.com to see what it offers). You might feel it's a lot of extra reading when all you want is to get down to business doing your game but in the end you will absolutely love it.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
Bookmarks