Okay, so I have a science fair project and I decided on doing a series of programs that show the simpleness behind hacking a password. Each program increases in complexity starting with a four digit password, and ending with a 10 digit letter and number combo that is case sensitive. Right now I need to figure out a way to have my program be able to convert chars into ints, so that I can do a counter and then I also need to be able to convert the ints, back into chars. Thank you! Love to get an answer back ASAP and...MERRY CHRISTMAS!
Well I haven't reached the 10 digit combo program yet, I'm working on the second program in the series which would allow the user to enter a five digit letter only password that is uppercase only, and I need to convert each of those letters that they input, into a number. From there I would just set a counter and a bunch of either switch of if-else statements to check where the number should go. But. How do I get The inputted letters to change to a number????? Aslo, what headers would I use?
How do I get The inputted letters to change to a number
MiiNiPaa wrote:
int i = static_cast<int>(c);
Inside computer there are no characters. There are numbers. Computer uses something called character table to know that, say , character number 97 sould be drawn as 'a'
A digit '0' in fact is a character number 48 in ASCII
And also it is binary numbers. Almost all assembly commands (aside fro those which threats register content as address) works as arithmetic operations.
I'm still confused, so what is the code in order to get it to change into a number for me to be able to put a counter? and what are the headers necessary?
Line 6: create a table all possible (and some impossible) base ASCII characters can be indices of. Base ASCII characters have codes 0-127.
Line 8: read character from standard input and save it to c, until we hit newline
Line 9: increment corresponding element of table. Uses char as int. (no actual conversion as char is already an integer)
Line 10 - 11: loop over the table and print all characters encountered at least once. Uses trick to convert integer to char. Commented out line uses explicit cast instead.
hmmm ok so if i wanted it to go from "A" to "Z" I would input it something like with the frequency table: int frequency_table[90] = {65}; is that right?
no ur not understanding my program lol, her lemme try to explain better: My program should do output something like:
Please enter your maximum five digit uppercase alphabetical only password: PGGS
AAAAAAABAAACAAADAAAEAAAFAAAGAAAHAAAIAAAJAAAKAAALAAAMAAANAAAOAAAPAAAQAAARAAAS
It can be formatted differently of course and the format shouldnt be too hard to do but i need it to like loop around if i could i would show u a file of what i have done for my first program.
Start with string "AAAAA". Test it and increment last symbol until it is larger than 'Z'. Then set last symbol to 'A' again and increment second-to last, start again with last. When second to last will be larger than Z, set it to 'A' and inctement previous symbol, etc.
Code I posted earlier does completely different thing. It counts frequenvy of letters in entered string and exis only to show int←→char conversion.
Here http://www.cplusplus.com/forum/general/151874/#msg790526 I show how to loop over character range easily.