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 


Help, what am I doin gwrong? ._. C

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ParlorGem
How do I cheat?
Reputation: 0

Joined: 22 Apr 2012
Posts: 2

PostPosted: Tue Jul 24, 2012 9:47 am    Post subject: Help, what am I doin gwrong? ._. C Reply with quote

Hey there,

I was wondering if you could help me out on this, I'm stuck don't know what to do. I am making a code where there's a fuction that returns the values +1 in case a number appears. Here's a small code I made on another one to not post so much code and this isn't working.

When I call the fuction, it just doesn't add up to the variable. Is there any other easier way or what am I doing wrong?

-------

Code:
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>


int add(int b,int r,int p,int i,int h,int l,int c1,int c2,int c3,int d1,int d2,int d3)
{

//cores
b++;
r++;
//parimpar
p++;
i++;
//altobaixo
h++;
l++;
//coluna 1 2 3
c1++;
c2++;
c3++;
//duzia 1 2 3
d1++;
d2++;
d3++;
return b , r , p , i , h , l , c1 , c2 , c3 , d1 , d2 , d3;
}

int main()

{

int num;
int black=0,red=0,par,impar,high,low,col1,col2,col3,du z1,duz2,duz3;

while(num!=99)
{
printf("num - ");
scanf("%d",&num);

switch(num)
{
case 0:
add(black,red,par,impar,high,low,col1,col2,col3,du z1,duz2,duz3);
break;
}
printf("Preto = %d",black);
}

getch();
}

-----

Hope someone can help me out, thanks!

_________________
Learning how 2 program kthx
Back to top
View user's profile Send private message
vnlagrla
Cheater
Reputation: 0

Joined: 10 Apr 2011
Posts: 33

PostPosted: Tue Jul 24, 2012 9:13 pm    Post subject: Reply with quote

so you just want it to add 1 each time add() is called?
instead of b++;
try b += 1;//the same as b = b + 1;
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed Jul 25, 2012 10:30 am    Post subject: Reply with quote

Both are equivalent. That is not his problem at all. The problem is that he is passing the value of the variables. So when the value is incremented, it simply increments the local stack variable. To fix this, pass pointers to the variables. Then in the function, dereference the variable and increment that.

For example:

Code:
#include <stdlib.h>
#include <stdio.h>

void inc_var(int * i)
{
        (*i)++;
}

int main(void)
{
        int i = 0;

        printf("Before = %d\n", i);
        inc_var(&i);
        printf("After = %d\n", i);

        return EXIT_SUCCESS;
}
Back to top
View user's profile Send private message
ParlorGem
How do I cheat?
Reputation: 0

Joined: 22 Apr 2012
Posts: 2

PostPosted: Fri Jul 27, 2012 9:24 am    Post subject: Reply with quote

Thanks, I was thinking about using pointers but really didn't knew if it was the solution.
_________________
Learning how 2 program kthx
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