菜鸟求代码详细解释
各位高手好!
别人的一段代码看不明白,
跪求详细解释!
int str,sym,tmp,val;
int symbol_count;
// open file
FILE *from;
char line[MAX_LINE];
from = fopen(filename,"r");
symbol_count=0;
for (num_strings=0; fscanf(from,"%[^\n]\n",line)!=EOF; num_strings++) {
for (sym=0,tmp=99; tmp>1; sym++) {
tmp=sscanf(line,"%d %[0-9 ]",&val,line);
}
if (symbol_count < sym)
symbol_count=sym;
}
cout << "\nmax sequence length = " << symbol_count << "\n";
cout << "number of strings = " << num_strings << "\n";
rewind(from);
strings = new int* [num_strings];
string_len = new int [num_strings];
for (int i=0; i<num_strings; i++) {
strings[i]=new int [symbol_count];
for (sym=0; sym<symbol_count; sym++) // initialize array to -1
strings[i][sym]=-1;
}
红色部分是看不懂的部分,不知道读取的文件格式应该是怎么放置内容的!
求详细解释!
多谢了先!