For some reason when I store a char and an int into my struct it's storing the ascii value into the object. I can test with cout in the function where the input is taken but once i send the char to another function and cout it there it outputs an ascii value for both the char and the int as well as store those ascii in my struct.
my struct:
1 2 3 4 5 6 7
struct pcb{
string processName;
char processClass;// a = application, s = system
int priority; // -127 to 128
int state; // 0 = Running, 1 = Ready, 2 = Blocked, 3 = Suspended Ready, 4 = Suspended Blocked
int memory; //memory required
};
Original section of function with input:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void createPCB(queueList*& listName)
{
string pname;
char pClass;
int pPriority;
bool success = false;
pcb * tempPCB;
while (!success)
{
cout << "Enter the process name (must be unique):";
getline(cin, pname);
cout << "Enter the class (a - application | s - system): ";
cin >> pClass;
cout << "Enter the Priority(-127 to 128): ";
cin >> pPriority;
tempPCB = setupPCB(pname, pClass, pPriority, listName);
function that is inputting the char and int as ASCII values
tempPCB = setupPCB(pname, pClass, pPriority, listName); // putting class 2nd, priority 3rd
// but the function takes priority 2nd and class 3rd
pcb* setupPCB(string name, int priority, char processClass, queueList*& listName)
Your compiler really should be giving you a warning about this. Conversion to a lower type (int to char) typically throws a warning... that should have tipped you off. If you're not getting a warning, you might want to tweak your warning level in your compiler settings.