# Confused about arrays in C [closed]

Hey guys I am learning the basics of C language and I am a little bit confused about how to use arrays.

I mean what are they used for?

## closed as off-topic by Alexandre Vaillancourt♦, Josh♦Jan 15 '16 at 16:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – Alexandre Vaillancourt, Josh
If this question can be reworded to fit the rules in the help center, please edit the question.

• This should be on stackoverflow since this is not related to gamedev. – DH. Jan 15 '16 at 16:09
• I would recommend to you first learn how to use the language (C or C++… your choice) before attempting to develop a game, on your first question you asked about a basic 2D game, but if you don't know how to use the language, then that will be almost impossible to do at the moment – rlam12 Jan 15 '16 at 16:21
• Sorry...I was too excited about developing. – Jithesh Jan 16 '16 at 5:57

That's an array of type std::string[]. Or if you want to get really technical, it could be considered an array of type ItemConsumable[] (because "Steve" is a valid string, but you certainly can't buy him!)

In game programming, you would just arrays (or lists) to keep track of objects, actions, events, or other data. It entirely depends on the use. You might even have a (two dimensional!) array that your units use for pathfinding.

• String must be std::string. – HolyBlackCat Jan 15 '16 at 16:10
• @HolyBlackCat You would be correct. I don't work in C so my syntax and proper declarations are more than rusty, but examples are valid no matter what language. – Draco18s Jan 15 '16 at 16:12
• That's ok, answer and examples are good. I just decided to tell it to you instead of editing. – HolyBlackCat Jan 15 '16 at 16:14
• @HolyBlackCat Just edit it, dude, I won't be offended. :) I've accepted a couple of edits where the editor was more correct than I had been (variable naming, for instance), or for minor things like syntax errors or spelling. Comments just makes me think, "FFS, just edit it yourself." – Draco18s Jan 15 '16 at 16:17

First of all. C is not the same as C++. (They are different programming languages)

Now, (trying to explain without making it too complicated), arrays are lists of variables.

(The image has Numbers with capital letters, my fail, ignore that, shouldn´t have the starting letter in capitals)

For example, int numbers[10]; is an array that contains space for 10 ints (numbers).

You can access values from the array ("list"):

exampleIntVariable = numbers[1];


Our variable will have the value of the 2ND number in our list (The first one is numbers[0])