vb 读取文本文件 数据放到二维数组中,

2024-12-14 04:52:34
推荐回答(2个)
回答1:

(ByVal filepath As String) As String
Dim s As String
Open filepath For Input As #1
While Not EOF(1)
Line Input #1, sline
s = s & sline & vbCrLf
Wend
Close #1
openfile = s
End Function

如果是按一行一行读取进数组 你可以用

dim a
a = split(openfile(App.Path & "\1.txt"),vbcrlf)

回答2:

给你个例子
#include
#include
int main(){
int k=0;
int m=0,n=0,l=0;
char b[200][200];
char a[200][200]={0};
ifstream file("sdasd.txt");
while(!file.eof()){
file.getline(a[k],200,'\n');
if(strstr(a[k],"#"))
continue;
k++;}
for(m=0;m<5;m++){
for(n=0;n<200;n++){
// if(a[m][n]==':'||a[m][n]=='/')
// continue;
// else
{b[m][l]=a[m][n];
cout< l++;

}