求助:如何获取账号的其中几位数字?Help: How do I get a few digits of my account?

 

求助:比如现在登录的交易账号是12345678,我想让abc这个变量值等于账号的后4位数字(即让abc=5678),要怎么写代码呢?

Help: For example, if the trading account is 12345678, and I want the value of the variable abc to be equal to the last 4 digits of the account (i.e., let abc=5678), how to write the code?

 

获取账号,然后转换成字符串,再取后四位字符。

string GetLastFourNumbers()
{
   long accountNum = AccountInfoInteger(ACCOUNT_LOGIN);
   string str = IntegerToString(accountNum);
   int len = StringLen(str);
   if(len<=4)return(str);
   return StringSubstr(str,len-4,4);
}