Hello all,
i am new to C++ and im writing a little encryption program for fun. It requires the user to enter a 'passkey', which is a string (numbers, and letters). Then the program defines the ASCII value of all of the characters, and places them in the string - one after another. Then i want to use the "atol" function, to transfer the value of the string into the defined integer variable. This is where the program crashes and dispalys an error message "Access Violation (Segmentation Fault)".
Here is the code for that section:
char* value;
int num_value;
cout << "\n" << "What would you like the PassKey to be? ";
cin >> passkey;
//**Convert to ASCII in this followiing Section**
int x = 0;
while (passkey[x] != '\0')
{
value += int(passkey[x]);
x++;
}
num_value = atol (value);
//**End of ASCII convert.**
The program crashes when it gets to "num_value = atol (value);"
. I am not sure what the problem is. Can you please help, im stuck.