Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 458 Vote(s) - 3.43 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ Tutorial - Arrays

#1
Hello CC Members, and welcome to my basic array tutorial!

In order for you to understand this tutorial, You'll need basic c++ knowledge such as knowing how to get input and output by including the iostream and other important things like for loops.

I'll break this tutorial into five sections:

What's an array?

By now you're probably wondering what an array is. I'll do my utmost to explain what it is.

Basically, an array is a variable that can hold multiple different values of the same type.

For example:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


How do we declare an array then?

Good question!

An array is usually declared like this:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Here's an example of me declaring an int array:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


But this not enough because we need to

Initialize the array!

What does it mean to initialize an array?

Basically, when you are initializing an array, you are giving values to the integers in the array. Confusing? Here's an example of what I mean:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


You can leave the [] empty. What will happen then is that the compiler will give just enough space for all those numbers to fit. It basically assumes a size that matches the number of values that is between the braces {}.

Accessing the array!

Wouldn't this be useless if there were no way to access it? I think so. Luckily, you can access individual elements in the array and assign values to them. The format is as follows:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


It's pretty easy! Here's an example:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Let's do an experiment!

Let's try and use the array to make a message!


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


If there is something about this concept that you can't seem to 'grasp', don't hesitate to ask me questions. I won't bite, I promise!

I'm really sorry if this was hard to understand. This tutorial isn't complete yet. I'll add more things to it eventually. Thanks for reading, and I hope this tutorial helped aid you in the process of learning c++!
Reply

#2
Quote:(07-20-2013, 09:21 PM)Eternity Wrote:

[To see links please register here]

I didn't know you could this much c++ o.O

Good work bro <3

Thank you! And this isn't really that advanced, It's just basics!
Reply

#3
I didn't know you could this much c++ o.O

Good work bro <3
Reply

#4
Very nice tutorial man!
Reply

#5
Quote:(07-21-2013, 03:31 AM)Love Wrote:

[To see links please register here]

Very nice tutorial man!

Thank you, hope you understood it's contents.
Reply

#6
You can declare the integer within the for loop statement as well, to lessen the scope of that variable, even though it's not really significant here because the function ends after the system call.

Why are you using system("PAUSE") though? A C++ tutorial for someone to learn from shouldn't have anything showing system() calls unless there is a topic about it specifically. There's no reason to use system("PAUSE") here.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through