level 13
自定义函数如:function myf(x,y,z),
调用该函数,当y,z缺省,只输入x值,即:myf(x)时,有意义
2016年07月25日 04点07分
1
level 13
function f_xsjq(s)//读取文件,全文内容(英文)显示
variablef1 = fopen(s, "rb","UTF-8")
variable n=get_file_size(s)
variable mat = alloc_array(n)
fread(f1, mat, 0, n)//fread(f1, mat)
variable str = conv_ints_to_str(mat)
return str//printf("%s\n",str)//print(str)
fclose(f1)
endf
function f_xsjq(s,x,y)//读取文件,内容(英文)部分显示
variablef1 = fopen(s, "rb","UTF-8")
variable n=get_file_size(s)
variable mat = alloc_array(n)
fread(f1,mat)
if(or(x<0,y<0,x+y>n))
return "get_file_size("+s+")=="+n+"; "+x+","+y+"输入错误"
else
variable str=strsub(conv_ints_to_str(mat),x,y)
return str//printf("%s\n",str)//print(str)
endif
fclose(f1)
endf
2016年07月25日 06点07分
5
s⇒文本路径字符串 x⇒截取起点(非负整数) y⇒截取长度(非负整数)
2016年07月25日 06点07分