When I moved in Python I remember that I could do a if
if any assignment or operation returned error. Like this
int v[]={1,2};
int v1;
if((v1=v)==ERRO)
//faça isso;
Is there anything like this in C?
When I moved in Python I remember that I could do a if
if any assignment or operation returned error. Like this
int v[]={1,2};
int v1;
if((v1=v)==ERRO)
//faça isso;
Is there anything like this in C?
C is a static, weak-typed language, the opposite of Python that is dynamic and strong. You can not change one type of the variable, as you can in Python, but you can interpret one data as if it were another. It is the function of the programmer to solve this in the code.
Actually this is a programming error, so you should fix it and not try to check in the code if everything worked out. If it was another example it might be that it would make sense to do a check, but not this one.
To be honest, I think this same code written in Python would be pretty bad and possibly a bug too, but I do not know, it might have a context that I do not know.
Depending on the compiler and the configuration this will give compilation error, then you do not even have to do this.
See the ideone that does not even compile.