If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

a project for beginner

Is there a project for beginners that could take a little bit of time that would teach them alot about coding? Maybe give some ideas so i know what i can do and plan it out. Right now i have learned:
cin
cout
if
case
switch
system
variables
strings/chars
fstream
while loops
messageboxes
error fixes
putting it together
some other things i cant remember.

If you have anything i can learn to do that would be greatly appreciated.

Re: a project for beginner

I hate cppreference. They tell you about the function, but not where to find it. I can't tell you how many times I needed a function, googled it, found how to use it on cppreference, then spent another half an hour searching online to figure out what header file to include. I recommend buying a good C++ book instead.

Re: a project for beginner

Originally Posted by ninja9578

I hate cppreference. They tell you about the function, but not where to find it. I can't tell you how many times I needed a function, googled it, found how to use it on cppreference, then spent another half an hour searching online to figure out what header file to include. I recommend buying a good C++ book instead.

They tell you exactly where to find it. For example, here is the list of standard C++ algorithms.

Re: a project for beginner

The std::vector is a wonderful container, you can for example, declare it with a particular size:

Code:

//#include <vector>
std::vector<T> vec(size);

where T represents the type you want to vector to hold, and size is the size you want the vector to be, e.g. the following:

Code:

std::vector<int> intvec(100);

declares a vector called intvec that holds 100 elements of type int. You can now access those 100 elements just like a standard array if you like:

Code:

for(int i(0); i<100; i++)
{
intvec[i] = i;
}

The above loop doesn't test how big the vector is, so if I made the vector 1 element bigger by pushing a value onto the back (end) of the array

Code:

intvec.push_back(0); //The vector now holds 101 elements

and then ran the loop, the loop would still only assign 100 elements. You can create a loop that assigns the number of elements in the vector by checking its size:

Code:

for(int i(0); i<intvec.size(); i++)
{
intvec[i] = i;
}

If you compile the above loop you will most likely get a compiler warning for the part highlighted in red, and the warning will be telling you that there is a type mismatch in that vector<T>::size() returns a size_t type (not necessarily true, but has been on all implementations that I have tried), and you are comparing this against an int (the variable i), therefore there is a possible loss of data if the loop is looping over a very large number of elements. Since that isn't going to be a problem for reading a handful of elements from a file, you can tell the compiler that you know about the problem and are ok with it, by adding in a static cast.

Anyway, back to the std::vector. You can create one without any elements and then use push_back to insert elements at the end of the vector.

You should never attempt to access a vector location that is greated than size()-1, as the element will not exist and it attempting to make the access will yeild undefined behaviour.

The nice thing about std::vector is that you do not need to worry about memory allocation - it handles that for you. Now, to read the integers from a file (in the format described in the first of my posts in this thread) using vector you could do:

Re: a project for beginner

Originally Posted by PredicateNormative

If you compile the above loop you will most likely get a compiler warning for the part highlighted in red, and the warning will be telling you that there is a type mismatch in that vector<T>::size() returns a size_t type (not necessarily true, but has been on all implementations that I have tried)

What is guaranteed is that std::vector<int>::size_type is an unsigned integer type but int is a signed integer type.

Originally Posted by PredicateNormative

you can tell the compiler that you know about the problem and are ok with it, by adding in a static cast.

Yes, except that the code example demonstrates casting from std::vector<int>::size_type back to std::vector<int>::size_type. Your intention would be to cast to int:

Re: a project for beginner

Re: a project for beginner

Text based hangman,

Text based poker,

In the mid to late 70's there was a common set of games like lunar lander, trek and slots.

Dice oriented games.

Of course, really simple (almost nonsense) tests of looping from 0 to something to see how fast the computer could count. In the 70's we were using BASIC, so 500 integer increments per second was about the fastest we'd see.

In assembler we might get 50 to 100 thousand per second.

If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).

Re: a project for beginner

Originally Posted by JVene

Of course, really simple (almost nonsense) tests of looping from 0 to something to see how fast the computer could count. In the 70's we were using BASIC, so 500 integer increments per second was about the fastest we'd see.

In assembler we might get 50 to 100 thousand per second.

I have already done that it is on the ragezone website. I am actually looking for something that has a purpose. Games are pretty useless when text based.