I am A needy little idiot
I am A needy little idiot
If I wanted to define a variable type that was an array of multiple character arrays like for an inventory or a list of words or sentences.
Could you use a struct?
like
list Inventory[4]
and it would have four 20 byte strings 0, 1, 2, and 3
Really, I want to make my own custom variable that I can put in a header file.
If this is too complicated of a question just ignore me and my ignorant little unworthy self.
Also do you have any good suggestions for C++ Programming books.
Could you use a struct?
like
list Inventory[4]
and it would have four 20 byte strings 0, 1, 2, and 3
Really, I want to make my own custom variable that I can put in a header file.
If this is too complicated of a question just ignore me and my ignorant little unworthy self.
Also do you have any good suggestions for C++ Programming books.
Last edited by Alacaster on April 8th, 2017, 12:01 am, edited 1 time in total.
You can't be betrayed if you don't have any friends.
Why live? Cause why not.
Why live? Cause why not.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: I am A needy little idiot
Code: Select all
struct Inventory
{
char item_name[20]
};
Inventory items[4]
As long as your arrays inside the struct are defined as static arrays like it is here, you can store the struct with a single write command.
Code: Select all
#include <fstream>
std::ofstream file("inventorylist.inv", std::ios::binary);
file.write(reinterpret_cast<char*>( items ), sizeof(Inventory) * 4 );
file.close();
As for the book thing, don't have any suggestions. There are a crap ton of resources online that you can read through and learn the ins and outs of C++.
cplusplus.com and
cppreference.com
are just two of the ones I use. I know cplusplus.com has a tutorials series that you can go through, plus lots of examples on how to use everything in the Standard Template Library, plus a forum where people have asked questions and have had them answered. It's like an all in one package.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: I am A needy little idiot
Thanks
You can't be betrayed if you don't have any friends.
Why live? Cause why not.
Why live? Cause why not.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: I am A needy little idiot
Was wondering if that is what you wanted by your description, glad it helped.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: I am A needy little idiot
As for books, I have never read them, but a good intro seems to be C++ Primer, and a good in-depth look would be Bjarne's book.
Chili
Re: I am A needy little idiot
Hi
Concerning books, I really liked the C++ books from Herbert Schildt, he explains in a very clear style in my opinion (just c++ though, no windows / graphics programming and only C98c98):
https://images-na.ssl-images-amazon.com ... SV6NQL.jpg
The book(s) by Peter Walsh are not bad either (DirectX 10, maybe there's a newer version now):
https://images-na.ssl-images-amazon.com ... 3,200_.jpg
Concerning books, I really liked the C++ books from Herbert Schildt, he explains in a very clear style in my opinion (just c++ though, no windows / graphics programming and only C98c98):
https://images-na.ssl-images-amazon.com ... SV6NQL.jpg
The book(s) by Peter Walsh are not bad either (DirectX 10, maybe there's a newer version now):
https://images-na.ssl-images-amazon.com ... 3,200_.jpg
Last edited by Byteraver on April 7th, 2017, 7:34 pm, edited 1 time in total.
Re: I am A needy little idiot
do you have any recommendation for Directx game develop books, I mean, some book to read after the C++ primer and more about game develop.chili wrote:As for books, I have never read them, but a good intro seems to be C++ Primer, and a good in-depth look would be Bjarne's book.