改为
if( (pte = (char *)realloc( pte, sizeof(char) * (cusiz + sLine + 2) )) == NULL )
char fileName[] = "C:\\Users\\lenovo\\Desktop\\Ch2.txt"
if( (txt = readText( fileName )) == NULL )
改为
if( (txt = readText( argv[1] )) == NULL )
这样可从命令提示符运行程序, 以要程序中要访问的文件名做参数。
TextCounts calcCounts( txt )
改为
counts = calcCounts( txt )
第一:栈为空时TOP=-1有好处,那就是编写程序时用数组存储时
插入一个数据data时
直接
top++;
a[top]=data;
------------
取栈顶时也可以
直接取a[top]=data;
如果top=0的话则需要写成a[top-1]=data;
所以用top=-1在编程时可以减少许多a[top-1]的现象
但是也有缺点就是栈的长度不等于top,而是top+1;
同理top=0反过来了,top的值等于栈的长度,
但是编写取栈顶等函数时老需要a[top-1]
个人觉得top=-1比较好
第二:
assert( tpos<Length-1 ) //
elmlist[++tpos] = item
你没看到下一句,如果tpos=9 那elmlist[++tpos]=elmlist[10]就越界了
Private Sub Command1_Click()
Dim Length As Integer, i As Integer, str As String, str2 As String, str3 As String
str2 = Text1.Text '被搜索内容
Do While 1
str = str2
Length = InStr(str, Chr(13)) - 1 '返回换行符的位置
str2 = Mid(str, Length + 3) '保存等待查找的字符串
str = Mid(str, 1, Length) '获得第n行的内容
Length = InStr(str, "-") - 1 '返回"-"分隔符的位置
str3 = Mid(str, 1, Length) '保存等待匹配的内容
If str3 = Text2.Text Then
Length = Length + 4
str = Mid(str, Length + 1)
Text3.Text = Mid(str, 1, InStr(str, "-") - 1)
Text4.Text = Text3.Text
Length = Len(Text4.Text) + 4
str = Mid(str, Length + 1)
Text5.Text = Mid(str, 1, InStr(str, "-") - 1)
Length = Len(Text5.Text) + 4
Text6.Text = Mid(str, Length + 1)
Exit Sub
End If
If InStr(str2, "-") = 0 Then Exit Do
Loop
Text3.Text = "没"
Text4.Text = "有"
Text5.Text = "找"
Text6.Text = "到"
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)