Is there a way to pass a hex value to an array element? I've been unable to find anything other than how to modify a stream such as
for (int i=0; i<1024; i++)
{
cout<<hex<<i;
}
but I need to modify the value I pass to an array (the value is to represent a memory address in a virtual memory simulation) and that value can't be a string as I need to compare it and search it as a number, a hexadecimal integer.
To clarify, how do I modify/implement the following code to pass the variable i in hexadecimal form to my array?
int memory[1024];
for (int i=0; i<1024; i++)
{
memory[i]=hexadecimal_verision_of_integer_i;
}
Thanks Peter87 but I do understand that. Sorry I wasn't terribly clear in my post but as I mentioned in the array is meant to simulate a memory system and thus it displays addresses in hexadecimal. The program is meant to output a log file which will display hexadecimal addresses. Can you help at all? Is there a function you know which will handle to conversion?
Thanks so much for your help guys. Peter87 you are right, I was over engineering the solution and it makes much more sense to do the conversion at the end! I have another issue however which is to do with reading hex numbers in from a .txt file but I think I should start a new threat for that