Or will they be left together?
I realise this may well be a stupid question but I'm 30+ without sleep at this point I'm doubting my own name and don't want to continue in the wrong direction
1 2 3 4 5 6 7
string number = "123456"char Array[];
for(int i =0; i < Array.size -1; i++)
{
Array[i] = (char)number[i]
}
If your string looks like this: "1 32 26 12 8"
then the array assignment would go like this:
Array[0] = '1'
Array[1] = ' '
Array[2] = '3'
Array[3] = '2'
Array[4] = ' '
etc...
By the way, this char Array[]; is an empty array, which is not valid. It is probably a lot simpler/safer to just use std::string which can be treated as an array of characters, and takes care of its own size (if used appropriately).
I only wrote that code as a quick example of my thought pattern, I was sure it was each character to a cell as you've both confirmed, but I thought it best to check :) Thank you
The reason I'm using array is I want to search through the numbers returned by my Alphabet to Decimal code, but I am having trouble loading it into the array as each iteration passes
@Chervil. Is it fine moving the integer numPass into the char array passwordArray, they're not of the same type? And if so, it's probably not optimal is it?
Is it fine moving the integer numPass into the char array passwordArray, they're not of the same type? And if so, it's probably not optimal is it?
Well, if an int occupies 4 bytes and a char 1 byte, clearly a lot of data is discarded. But so long as the value is in the range +127 to -128 nothing should be lost. Not optimal, I agree.
It is when I am shifting them to that value! that is the entire point of this okay I can't use capitals, but I am working on using isupper functions to convert any caps a user inputs to lowercaser, I then run it through the returnVal function to convert it to a decimal and subtract the relevant amount from the number eg. a is 97 subtract 96 and I have 1.
But I'm not even fused with the shift value, I just want a consistent decimal result from whatever a user types in, so that I can manipulate what they type into a key for my encryptions
First convert to upper case (use function toupper() on each character).
Next find the position of the character in the alphabet. A naive approach is to simply subtract the letter 'A' and add 1, though there are more robust solutions.
The most tricky part is to convert the resulting number into character format. Since there may be double digits, a simple assignment to an array won't work.
Your specification is ambiguous, I'll suggest something, but it may not be what you want.
Thank you! that works, well I won't say perfectly as you've all made clear this isn't really the best way to be doing this, but, it works, so thank you very much