Please, why?
Try this
void OnStart() { uchar u_ch; for(char ch=1;ch<=9;ch++) { u_ch=ch; Print("ch = ",ch," u_ch = ",u_ch); if(ch==9) break; } }
Try this
Thank you !!
I want to know why "uchar u_ch;"And"for(char ch=1;ch<=9;ch++) "I can't use ch for both of them。
- helloea: I want to know why "uchar u_ch;"And"for(char ch=1;ch<=9;ch++) "I can't use “ch” for both of them。
You can. What you shouldn't do is declare them twice. What you can't do is not declare one at all.
uchar ch; for(char ch=1;ch<=9;ch++){ u_ch=ch;
Your original image declared a variable ch (unsigned character.) Then created a new variable in the for loop with the same name. This hide the outer ch (very bad practice.) If you wanted to use the original ch and not create a new one, you would just write for( ch=1; …)
-
No where in your code did you ever declare a variable u_ch, thus your "undeclared identifier."
- Please don't post an image of code or the editor — it is generally to small to be read.
Only use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor
-
You can. What you shouldn't do is declare them twice. What you can't do is not declare one at all.
Your original image declared a variable ch (unsigned character.) Then created a new variable in the for loop with the same name. This hide the outer ch (very bad practice.) If you wanted to use the original ch and not create a new one, you would just write for( ch=1; …)
-
No where in your code did you ever declare a variable u_ch, thus your "undeclared identifier."
- Please don't post an image of code or the editor — it is generally to small to be read.
Only use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor
Thank you, I seem to know the first and second, the third I will remember, thank you again!Hope we communicate more!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Please, why?