Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How can I make a Dynamic array?  (Read 1760 times)

0 Members and 1 Guest are viewing this topic.

louie

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
How can I make a Dynamic array?
« on: August 29, 2015, 09:14:21 am »
Whenever I try to do something like:
int something[];
it results in the error:
error: storage size of 'something' is unknown
So I'm forced to do something like
int something[100];
But I want that variable to be a dynamic array, like:(some pseudo-code)
int something;
something[2] = 1
something[101] = 5
something[3] = 4
I hope someone can help me with this :S

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: How can I make a Dynamic array?
« Reply #1 on: August 29, 2015, 09:56:48 am »
This is not in any way an SFML question, but just use a vector.

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: How can I make a Dynamic array?
« Reply #2 on: August 29, 2015, 10:26:22 am »
http://bfy.tw/1X9s ;)
or a vector indeed.

I highly suggest that you get more familiar with C++, if you aren't, before you work with SFML, or you'll encounter many problems (and a bitch won't be one).
« Last Edit: August 29, 2015, 10:28:00 am by G. »

louie

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: How can I make a Dynamic array?
« Reply #3 on: August 29, 2015, 12:08:02 pm »
Ok I'll try using vector :)
something like this right?
#include <vector>
std::vector<int> a;

Satus

  • Guest

 

anything