I'm having problem to run this code involving the following function, I was trying to do conversion from char to integer. It ran well when I didn't use function. The sixth line gets me error. I was trying to get it worked as same function as the second code below but when I use function it didn't run well.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
void EnterTime (char& time1, char& time2)
{
stringstream str, str2;
cout << "Call started at (hhmm): ";
cin.get(time1, 3); cin.get(time2, 3);
str << time1;
str2 << time2;
int w, x;
str >> w;
str2 >> x;
cout << w << endl;
cout << x << endl;
}
If you want to pass an array to a function, do either this: void EnterTime (char * time1, char * time2)
or this: void EnterTime (char time1[], char time2[])
If you want to pass an array to a function, do either this: void EnterTime (char * time1, char * time2)
or this: void EnterTime (char time1[], char time2[])
I've tried your suggestion and it did get me no error but the output still didn't work out the way I want it to be as shown in the code below.