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 Pointer Issues

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

Joined: 13 Jun 2007
Posts: 80

PostPosted: Fri Nov 23, 2007 1:59 pm    Post subject: C Pointer Issues Reply with quote

Hey CE Forums, Im Back! I've got a program, but when it runs, it appends random text to the end of my string, I think I messed up with my pointer usage:
Code:
void brute(int length,char *file){
   if(file!="null"){
      
      out=fopen(file,"w");
   }
   char pass[length];
   memset(pass,0,length);
   int x;
   int y;
   printf("Brute.Length= %d\n",length);
   printf("Brute.File=%s\n",file);
   while(done(pass)==0){
      for(x=0;x<length;x++){
         y=pass[x];
         if(y==0){
            pass[x]=48;
         }
         else if(y>122 & x!=length){
            pass[x]=48;
            pass[x+1]++;
            
         }
         pass[x]++;
      }
      printf("Key: %s\n",pass);
      if(file!="null")
         fprintf(out,"Key: %s\n",pass);
      
   }
   if(file!="null")
      fclose(out);
}

Congrtats to anyone who gets it, ive waited days on another forum, but it seems like more people here can code...

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

Joined: 20 Aug 2007
Posts: 351
Location: russia

PostPosted: Fri Nov 23, 2007 2:28 pm    Post subject: Reply with quote

Errr... I'm looking at the code and kind of confused...

Nothing seems wrong on your pointer usage - though I'm just glancing at the code, not compiling it.

Your not setting x or y to any values though, just initializing them. Also - is Done() a function you have no included?

It's hard to tell what your doing wrong, because I'm not sure exactly what your doing. As long as you know that pass[x] returns the value located at position x. Meaning pass[x]++ isn't incrementing the pointer - it's adding 1 to the array...

Maybe if you post an example of the output it'd make this more clear, and what the output SHOULD look like.

First thing I'd suggest just from your description of the problem is to print out the characters you want using the length var you have using printf %c, not %s.

_________________
0x7A 0x61 0x72 0x74

TEAM RESURRECTiON
Back to top
View user's profile Send private message
Varreon
Advanced Cheater
Reputation: 0

Joined: 13 Jun 2007
Posts: 80

PostPosted: Fri Nov 23, 2007 2:58 pm    Post subject: Reply with quote

x and y are being used, as temporary holders for ascii values.
This should have become a variable length bruteforcer. Every time it iterates through the string, it increases the value of the first digit by one. If any digit other than the last one passes a lowercase z(ascii 122), then it sets it to a 0(ascii 48) and increases the next digit. Done() is a function that returns true if all the digits are ascii 122, or the highest value I want it to reach. Thanks again for helping.

_________________
Back to top
View user's profile Send private message
TheSorc3r3r
I post too much
Reputation: 0

Joined: 06 Sep 2006
Posts: 2404

PostPosted: Fri Nov 23, 2007 3:51 pm    Post subject: Reply with quote

char pass[length];
memset(pass,0,length);

should be

char pass[length];
memset(&pass, 0, length);

_________________


Don't laugh, I'm still learning photoshop!
Back to top
View user's profile Send private message
Varreon
Advanced Cheater
Reputation: 0

Joined: 13 Jun 2007
Posts: 80

PostPosted: Fri Nov 23, 2007 5:33 pm    Post subject: Reply with quote

I tried that, ran, and now theres no output from my program. I removed that, recompile, and theres no ouput. I guess recode the brute function a bit later.
_________________
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