Right, so you've read the title and you thought wanna be hacker eh? Wrong, I really just want to try this and make it as a cool gimmick to try it out and see what it would really do. I know this will not work over the internet and all that so i was just wondering what I should do after this part?
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
usingnamespace std;
int main () {
int i;
for (i= 0 ; i< 255; i++)
{
cout << i <<endl;
}
return 0;
}
I know its quite nooby but how do I expand on it and search for numbers like 552 instead of just numbers up to 255?
EDIT: Also how would I "use" this item on something for example MSN or some database field? I can't see how it would work just running the file? Again I do not plan to use a brute force tool to well, brute force as its not hacking ;)
Huh? I thought though that 255 was the maximum for an array?! And so basically if I typed 99999999, that in effect is a brute force tool? Then then next stage is work with letters by doing the same thing?
Ok I made a mistake alright? Anyway I am trying out with numbers right now and yes I know it has no use hence my first post, so if your not going to help me and you are going to spell check all my posts then can you leave and let someone actually help me?
I also ment how would I actually use it as once I have the code what would i do next -.-
Why does the series start at 1111111? What about 0000001?
Anyway, here's how it's done:
1 2 3 4 5 6 7 8 9 10 11 12 13
const size_t N=4;
char test[N]={0};
while (1){
for (int a=N;a>=0;a--)
std::cout <<test[a];
std::cout <<std::endl;
test[0]++;
for (size_t a=0;a<N-1;a++)
if (!test[a])
test[a+1]++;
if (!test[N-1])
break;
}
This will take a long time to complete. Incrementing N by 1 multiplies the running time by 256. N=8 should never finish, I think.
Why does the series start at 1111111? What about 0000001?
Anyway, here's how it's done:
const size_t N=4;
char test[N]={0};
while (1){
for (int a=N;a>=0;a--)
std::cout <<test[a];
std::cout <<std::endl;
test[0]++;
for (size_t a=0;a<N-1;a++)
if (!test[a])
test[a+1]++;
if (!test[N-1])
break;
}
This will take a long time to complete. Incrementing N by 1 multiplies the running time by 256. N=8 should never finish, I think.
WOW Kudos mate. Shame I don't understand little bits of it however I'll work my way through it. Am I right in saying you've used an algorithm?
... I suppose. Technically speaking, every program is an algorithm. This isn't what people think when they think "algorithm", though.
Brute force isn't an algorithm. It's merely a problem solving method.
My bad. I was going to do something else but forgot to update a different part in my head.
This one works, but you'll get something interesting if your send the output to the console:
I'm not sure it's what you want but you could do something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
srand((unsigned)time(0));
// Create a pseudo-random number between min and max inclusive:
int min = 0, max = 255, range = (max - min);
int randVal = min + int(range * rand()) / (RAND_MAX + 1.0)); // Create the pseudo-random number
unsignedchar myChar[256];
for (int i = 0; i < sizeof(myChar); ++i) {
myChar[i] = randVal;
}
myChar[255] = '\0'; // Null-terminate the array
std::cout << myChar;
if you want a pseudo-random number/character generator.
I'm fairly sure the range of an unsigned char is 0-255. I may be wrong, although I don't think I am.
It's non-standard but I guess you could also use the itoa function.
If that's nothing like what you want you should use Helios' solution. You want 0 - (upper bound of integer) right? Well that's what I think Helios is doing. Then, you could do 0-255 for an unsigned char if you want to do letters...