Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] an array

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Sun Nov 09, 2008 8:28 pm    Post subject: [C++] an array Reply with quote

I was making a script in c++ and thought
could I do a while event for an array

the array being like so [not sure how arrays work in c++]

array NUMBERS;
array NUMBERS = Array("1, 2, 3, 4, 5, 6, 7, 8, 9, 10");

and then have a while event where it repeats until it finishes, but using the number out of the array.

Basically

while(NUMBERS < 10){
PostMessageA("NUMBERS");
}

I know this code wouldn't work in a million years, but just as an example.
So it would keep saying a number until finished.

"1" "2" "3" "4" "5" "6" "7" "8" "9" "10"

Thanks a ton

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun Nov 09, 2008 8:44 pm    Post subject: Reply with quote

first off thats not how you define an array, learn the context.

and array is defined like

type var [sizeofarray];

so say an int array of 10

int varname[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

now thats not how you wanna go about it anyways

Code:


int var = 0;

while (var < 10)
{
printf("Value: %d", var);
var++;
}

_________________
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Sun Nov 09, 2008 9:04 pm    Post subject: Reply with quote

thanks. Another question, how would I make it do the array itself?
Like I tell it 3 and 100 and it automatically makes the array which numbers 3-100

nvm figured it out

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun Nov 09, 2008 9:09 pm    Post subject: Reply with quote

Code:


int max, min;

printf(" Enter your min and max: ");
scanf("%d", min);
scanf("%d", max);

int val[max];
int i=0;

while( i < max );
{
val[i] = min+i;
i++;
}


i think that should work.

didn't test it. but go for it

_________________
Back to top
View user's profile Send private message
nwongfeiying
Grandmaster Cheater
Reputation: 2

Joined: 25 Jun 2007
Posts: 695

PostPosted: Sun Nov 09, 2008 9:45 pm    Post subject: Reply with quote

I would think that the for-loop would be better for this (pun intended).
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun Nov 09, 2008 9:54 pm    Post subject: Reply with quote

yea, but i didn't feel like doing one Razz
_________________
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Sun Nov 09, 2008 10:49 pm    Post subject: Reply with quote

Well how would i make it start at 0000 and go up
so each number would be like

0001
0002
0003
0004
0005
0006
0007
0008
0009
0010

EDIT: nevermind, tried to do a function like

if (var < 10){
var = 000 + var;
}

and so on and so forth. harder way, but you gotta do what you gotta do amirite?

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Nov 10, 2008 9:11 am    Post subject: Reply with quote

ElectroFusion wrote:
Well how would i make it start at 0000 and go up
so each number would be like
Code:
int i;
for(i=min; i<=max; ++i)
   printf("%04d\n", i);
:D Anyway, the numbers are always stored with preceding zeroes, assuming that there's enough space in the variable. It's all about printing.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites