Link to home
Start Free TrialLog in
Avatar of chima
chima

asked on

C-style or function-style cast within a class method

This is my problem;
error C2664: 'isspace' : cannot convert parameter 1 from 'char *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Error executing cl.exe.          

This is the section of code;
if(isspace(pSSNumber[i])){ // Determines it is a tab or space

Note: pSSNumber is char* class_name::pSSNumber.

This is the solution, maybe?;
if(isspace(int(pSSNumber[i]))){ // Determines it is a tab or space }

Note: the int() cast.

My question is; is there a better solution.  It turns out that I have to do a cast on many statements.  Seems to me that there should be a global solution.
Avatar of Jasonss
Jasonss

how about writing your own isspace() function that take char*
ASKER CERTIFIED SOLUTION
Avatar of Exceter
Exceter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are you sure, pSSNumber's type is char* .

I almost think, in your program pSSNumber's type is char** .

Could you check it .
>> how about writing your own isspace() function that take char*

Because char* is a pointer not a char. char* variables are not used to store characters so writing a function that checked to see if its value was equivalent to a space character would be pointless.

Exceter
Avatar of chima

ASKER

I believe that Exceter is right.  pSSNumber is a two demensional array. I had move this section of code from main(){} and did not think of the input statment for the array.  I will try Exceter's solution, then issue the points.  I'm new at this, therefore writing my own isspace would require more skill than what I have.

Sidebar: I did not get an email telling me that there were responses.  I wonder why?  Also, I saw that the status was/is <unlocked> what does this mean?  I read the links for "New EEs" but have not come accross its meaning.
I hope and I think that the question is still open.
>> I did not get an email telling me that there were responses.  I wonder why?  

The email notifications get behind once in a while, the notification will show up.

>> Also, I saw that the status was/is <unlocked> what does this mean?

That simply means that you have not accepted an answer to this question yet.

Exceter
Avatar of chima

ASKER

Exeter, you're smart and quick, thanks.
It worked.  Silly me for thinking that the problem was more difficult.  I have another question, which I will post tomorrow.  Once again thanks.
You are most welcome.