Posted By: Emre
Redefining the same function in three way. - 04/06/20 05:35
Hi everybody. I have to ask this question because my programming knowledge is not good.
i want to use the skill of panel as strings, as follows;
No problem but every time i want to perform string operation, i have to specify that the skill is STRING*.
But i don't want to do that because it's annoying. So i redefined (i don't know if this is right word) str_cpy function in three different ways like this;
it works without problem. With this way, i can use "str_cpy" function for copy "string to skill" or opposite, or "skill to skill" without use STRING* pointer.
My question: is there any harm in this method? is it safe using this way?
i want to use the skill of panel as strings, as follows;
Code
test_panel.skill_x=str_create("");
No problem but every time i want to perform string operation, i have to specify that the skill is STRING*.
Code
str_cpy((STRING*)test_panel.skill_x,"test");
But i don't want to do that because it's annoying. So i redefined (i don't know if this is right word) str_cpy function in three different ways like this;
Code
#ifndef str_cpy function str_cpy(var var1,STRING* str) { str_cpy((STRING*)var1,str); } function str_cpy(STRING* str,var var1) { str_cpy(str,(STRING*)var1); } function str_cpy(var var1,var var2) { str_cpy((STRING*)var1,(STRING*)var2); } #endif
it works without problem. With this way, i can use "str_cpy" function for copy "string to skill" or opposite, or "skill to skill" without use STRING* pointer.
My question: is there any harm in this method? is it safe using this way?