Hello everyone,
I have a function in my program which receives (int)s from 0 to 9 , so it has a (int) arg, but I would like it to be able to recognize the '.' character. So what I'm doing is, just casting to (int) before passing it on to the function and inside it, casting it again to char and comparing against '.' to see if it's true. So that's how my code's like:
Qt Code:
myfunction( (int)'.' ); void myfunction( int value){ char aux = (char)value; if(aux == '.') cout << "TRUE"; else cout << "Number : " << value; }To copy to clipboard, switch view to plain text mode
Well, it works, it correctly recons that i'm passing '.' and do the actions I expect it to do. It also recognizes the digits.
I'm just wondering wether it is safe or not to do that, because it doesn't seem very elegant. Is it possible that in another architecture,compiler,operation system,whatever, it won't work out right?
Thanks in advance,
Luiz.
Bookmarks