请大家帮忙看看这段程序中出现的错误改怎么改啊?
程序目的是将线性表lb中出现而在线性表la中没有出现的元素插入到线性表la的末尾
程序的源代码如下:
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <malloc.h>
using namespace std;
#define INITSIZE 100
#define LISTINCREMENT 100
#define MIDSTRLEN 30
//typedef char ElemType
struct sqList
{
int length;
char* elem;
int listsize;
};
void InitList(sqList* L)
{
L->elem = (char*)malloc(sizeof(char)*INITSIZE);
L->length = 0;
L->listsize = INITSIZE;
}
void GetLen(sqList* L)
{
for (int i = 0; i < (L->listsize); i++)
{
if (*(L->elem + i) != '\0')
{
++(L->length);
}
}
}
char GetElem(sqList L, int i)
{
char e;
e = *(L.elem + i - 1);
return e;
}
void ListInsert(sqList* L, char e)
{
if (L->length >= L->listsize)
{
char* newbase;
newbase = (char*)realloc(L->elem, (L->listsize + LISTINCREMENT) * sizeof(char));
if (newbase == NULL)
{
cout<<"Error when alloting memory!"<<endl;
exit(0);
}
L->elem = newbase;
L->listsize = L->listsize + LISTINCREMENT;
}
char* p;
p = L->elem + L->length;
*p = e;
++(L->length);
}
void main (int argc, char* argv[])
{
sqList la, lb;
char str1[MIDSTRLEN];
char str2[MIDSTRLEN];
InitList(&la);
InitList(&lb);
ifstream infile("input.txt");
if (!infile)
{
cout<<"input.txt can't be opened!"<<endl;
system("pause");
exit(0);
}
infile.getline(str1, sizeof(str1));
infile.getline(str2, sizeof(str2));
for (int i = 0; i <= sizeof(str1); i++)
{
if(str1[i] != '\32' || str1[i] != '\0')
{
*(la.elem) = str1[i];
++(la.elem);
}
}
for (int m = 0; m <= sizeof(str2); m++)
{
if(str2[m] != '\32' || str2[m] != '\0')
{
*(lb.elem) = str2[m];
++(lb.elem);
}
}
infile.close();
GetLen(&la);
GetLen(&lb);
for (int n = 1; n < lb.length; n++)
{
char e;
e = GetElem(lb, n);
for (int j = 0; j < la.length; j++)
{
if (*(la.elem + j) == e)
{
ListInsert(&la, e);
}
}
}
ofstream outfile("output.txt");
for (int k = 0; k < 2*(la.length); k++)
{
outfile<<(*(la.elem + k))<<" "<<endl;
}
outfile.close();
system("pause");
}
程序在c++ 2008下编译通过但运行时出现错误如下:
Windows 已在 rerg.exe 中触发一个断点。
其原因可能是堆被损坏,这说明 rerg.exe 中或它所加载的任何 DLL 中有 Bug。
原因也可能是用户在 rerg.exe 具有焦点时按下了 F12。
输出窗口可能提供了更多诊断信息。
输出窗口中的信息:
“rerg.exe”: 已加载“C:\Users\freedom\Desktop\rerg\Debug\rerg.exe”,已加载符号。
“rerg.exe”: 已加载“C:\Windows\System32\ntdll.dll”
“rerg.exe”: 已加载“C:\Windows\System32\kernel32.dll”
“rerg.exe”: 已加载“C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcp90d.dll”,已加载符号。
“rerg.exe”: 已加载“C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcr90d.dll”,已加载符号。
“rerg.exe”: 已加载“C:\Windows\System32\shimeng.dll”
“rerg.exe”: 已加载“C:\Windows\System32\apphelp.dll”
“rerg.exe”: 已加载“C:\Windows\AppPatch\AcLayers.dll”
“rerg.exe”: 已加载“C:\Windows\System32\user32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\gdi32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\advapi32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\rpcrt4.dll”
“rerg.exe”: 已加载“C:\Windows\System32\shell32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\msvcrt.dll”
“rerg.exe”: 已加载“C:\Windows\System32\shlwapi.dll”
“rerg.exe”: 已加载“C:\Windows\System32\ole32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\oleaut32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\userenv.dll”
“rerg.exe”: 已加载“C:\Windows\System32\secur32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\winspool.drv”
“rerg.exe”: 已加载“C:\Windows\System32\mpr.dll”
“rerg.exe”: 已加载“C:\Windows\System32\imm32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\msctf.dll”
“rerg.exe”: 已加载“C:\Windows\System32\lpk.dll”
“rerg.exe”: 已加载“C:\Windows\System32\usp10.dll”
“rerg.exe”: 已加载“C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6001.18000_none_5cdbaa5a083979cc\comctl32.dll”
HEAP[rerg.exe]: Invalid address specified to RtlValidateHeap( 00870000, 0087523F )
Windows 已在 rerg.exe 中触发一个断点。
其原因可能是堆被损坏,这说明 rerg.exe 中或它所加载的任何 DLL 中有 Bug。
原因也可能是用户在 rerg.exe 具有焦点时按下了 F12。
输出窗口可能提供了更多诊断信息。
程序“[1432] rerg.exe: 本机”已退出,返回值为 0 (0x0)。
请大家帮忙解答一下。
程序的源代码如下:
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <malloc.h>
using namespace std;
#define INITSIZE 100
#define LISTINCREMENT 100
#define MIDSTRLEN 30
//typedef char ElemType
struct sqList
{
int length;
char* elem;
int listsize;
};
void InitList(sqList* L)
{
L->elem = (char*)malloc(sizeof(char)*INITSIZE);
L->length = 0;
L->listsize = INITSIZE;
}
void GetLen(sqList* L)
{
for (int i = 0; i < (L->listsize); i++)
{
if (*(L->elem + i) != '\0')
{
++(L->length);
}
}
}
char GetElem(sqList L, int i)
{
char e;
e = *(L.elem + i - 1);
return e;
}
void ListInsert(sqList* L, char e)
{
if (L->length >= L->listsize)
{
char* newbase;
newbase = (char*)realloc(L->elem, (L->listsize + LISTINCREMENT) * sizeof(char));
if (newbase == NULL)
{
cout<<"Error when alloting memory!"<<endl;
exit(0);
}
L->elem = newbase;
L->listsize = L->listsize + LISTINCREMENT;
}
char* p;
p = L->elem + L->length;
*p = e;
++(L->length);
}
void main (int argc, char* argv[])
{
sqList la, lb;
char str1[MIDSTRLEN];
char str2[MIDSTRLEN];
InitList(&la);
InitList(&lb);
ifstream infile("input.txt");
if (!infile)
{
cout<<"input.txt can't be opened!"<<endl;
system("pause");
exit(0);
}
infile.getline(str1, sizeof(str1));
infile.getline(str2, sizeof(str2));
for (int i = 0; i <= sizeof(str1); i++)
{
if(str1[i] != '\32' || str1[i] != '\0')
{
*(la.elem) = str1[i];
++(la.elem);
}
}
for (int m = 0; m <= sizeof(str2); m++)
{
if(str2[m] != '\32' || str2[m] != '\0')
{
*(lb.elem) = str2[m];
++(lb.elem);
}
}
infile.close();
GetLen(&la);
GetLen(&lb);
for (int n = 1; n < lb.length; n++)
{
char e;
e = GetElem(lb, n);
for (int j = 0; j < la.length; j++)
{
if (*(la.elem + j) == e)
{
ListInsert(&la, e);
}
}
}
ofstream outfile("output.txt");
for (int k = 0; k < 2*(la.length); k++)
{
outfile<<(*(la.elem + k))<<" "<<endl;
}
outfile.close();
system("pause");
}
程序在c++ 2008下编译通过但运行时出现错误如下:
Windows 已在 rerg.exe 中触发一个断点。
其原因可能是堆被损坏,这说明 rerg.exe 中或它所加载的任何 DLL 中有 Bug。
原因也可能是用户在 rerg.exe 具有焦点时按下了 F12。
输出窗口可能提供了更多诊断信息。
输出窗口中的信息:
“rerg.exe”: 已加载“C:\Users\freedom\Desktop\rerg\Debug\rerg.exe”,已加载符号。
“rerg.exe”: 已加载“C:\Windows\System32\ntdll.dll”
“rerg.exe”: 已加载“C:\Windows\System32\kernel32.dll”
“rerg.exe”: 已加载“C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcp90d.dll”,已加载符号。
“rerg.exe”: 已加载“C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcr90d.dll”,已加载符号。
“rerg.exe”: 已加载“C:\Windows\System32\shimeng.dll”
“rerg.exe”: 已加载“C:\Windows\System32\apphelp.dll”
“rerg.exe”: 已加载“C:\Windows\AppPatch\AcLayers.dll”
“rerg.exe”: 已加载“C:\Windows\System32\user32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\gdi32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\advapi32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\rpcrt4.dll”
“rerg.exe”: 已加载“C:\Windows\System32\shell32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\msvcrt.dll”
“rerg.exe”: 已加载“C:\Windows\System32\shlwapi.dll”
“rerg.exe”: 已加载“C:\Windows\System32\ole32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\oleaut32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\userenv.dll”
“rerg.exe”: 已加载“C:\Windows\System32\secur32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\winspool.drv”
“rerg.exe”: 已加载“C:\Windows\System32\mpr.dll”
“rerg.exe”: 已加载“C:\Windows\System32\imm32.dll”
“rerg.exe”: 已加载“C:\Windows\System32\msctf.dll”
“rerg.exe”: 已加载“C:\Windows\System32\lpk.dll”
“rerg.exe”: 已加载“C:\Windows\System32\usp10.dll”
“rerg.exe”: 已加载“C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6001.18000_none_5cdbaa5a083979cc\comctl32.dll”
HEAP[rerg.exe]: Invalid address specified to RtlValidateHeap( 00870000, 0087523F )
Windows 已在 rerg.exe 中触发一个断点。
其原因可能是堆被损坏,这说明 rerg.exe 中或它所加载的任何 DLL 中有 Bug。
原因也可能是用户在 rerg.exe 具有焦点时按下了 F12。
输出窗口可能提供了更多诊断信息。
程序“[1432] rerg.exe: 本机”已退出,返回值为 0 (0x0)。
请大家帮忙解答一下。
...全文
相关推荐
解决thinkphp5未定义变量会抛出异常,页面错误,请稍后再试的问题
今天小编就为大家分享一篇解决thinkphp5未定义变量会抛出异常,页面错误,请稍后再试的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
浅谈Python程序的错误:变量未定义
Python程序的错误种类 Python程序的错误分两种。一种是语法错误(syntax error)。这种错误是语句的书写不符合Python语言的语法规定。第二种是逻辑错误(logic error)。这种错误是指程序能运行,但功能不符合期望,比如“算错了”的情形。 变量未定义的错误 Python程序中,变量需要先定义后使用。如果没有这样做,就会出现变量未定义错误。这属于语法错误。Pycharm中,语法错误会用红色的波浪线标出来,如图1所示。 图1 Pycharm中,语法错误会用红色的波浪线标出来 Python程序运行的错误信息 Pycharm中,程序运行出错了,会在运行窗口(即输入数据或输出
易语言改进程ID源码-易语言
易语言改进程ID源码
怎么实现按键精灵键盘改键.docx
怎么实现按键精灵键盘改键.docx
批量改文件名
批量更改文件名,改文件格式,在同一文件夹下,批量更改各文件的名,比量把jpg改为txt格式等。


