| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | VERY strange violation acception! |
Hi all!
(Using VAC++ 3.0 for OS/2)
I have a problem witch I will explain, but first, this is the file the
"messed up" part of the program are suppose
to read (the lines by the probbs, there are several line before that, wich
are commented out with "//", and a
few line after to...):
-----
// Default is On
Cls=On
// The Header keyword, is the string to be shown above every news
-----
When a was debugging, a made the program print every character it read, on
the first line not commented out,
and when it had gotten to "Cls=" it craches (more on this in the code).
Here is the important part of the code:
---
class conf
{
public:
char cls;
char *header;
char maxlen;
char *end;
conf (void);
~conf (void);
int get (void);
};
conf::conf (void)
{
header = new char[200];
end = new char[200];
}
conf::~conf (void)
{
delete[] header;
delete[] end;
}
int conf::get (void)
{
ofstream error ("Errors.Log", ios::app);
int *errorcode = new int;
*errorcode = 0;
char *ch = new char;
*ch = ' ';
int *state = new int;
*state = 0;
char *str = new char[200];
ifstream ctl ("MaxNews.Ctl");
if (ctl.fail())
{
ofstream error ("Errors.Log", ios::app);
error << "Error: Unable to open MaxNews.Ctl (Errorlevel 1)\n";
error.close();
ctl.close();
return 1; // Unable to open MaxNews.Ctl
}
while (*state == 0) // This takes care and skippes the lines that
are commented out, and leaves the
// first character on the next row in *ch.
{
ctl.get (*ch);
if (*ch == '/')
{
for (;*ch != '\n'; ctl.get(*ch))
;
}
else
*state = 1;
}
str[0] = *ch; // put that characted to the tmp-string
*state = 0;
cout << "\n";
do
{
cout << *ch << flush; // print every character (as I
was talking about)
*state++;
ctl.get(*ch);
str[*state] = *ch; // here is the bug, when the cout, has shown
"Cls=", on this line OS/2 sais that it's a
// program violation excpetion,
"Exception = c0000005 occurred at EIP = 10398"
// witch is SYS1808, and cause by code 0005.
} while (*ch != '\n');
str[*state] = '\0';
*state = 0;
while (str[*state] != ' ' && str[*state] != '\n' &&
str[*state] != '\0')
*state++;
str[*state] = '\0';
*state = 0;
if ((strcmp (str, "Cls=On")) == 0)
{
cout << " I will put [cls]s\n";
cls = 'Y';
}
else if ((strcmp (str, "Cls=Off")) == 0)
{
cout << " I will not put any [cls]s\n";
cls = 'N';
}
else
{
cout << " Error: Cls keyword\n";
error << "Error: Cls keyword (errorlevel 2)";
cls = 'Y';
}
error.close();
delete ch;
delete state;
return *errorcode;
}
conf config;
---
Now, I don't get it!!! I have allocated 200 chars of memory!!! How is a
program violation exception possible on the
5th char???
Anyone?
Thanx!
/ Peter Schuller [TeamOS/2] petersch{at}kuai.se
--- Squish v1.11
* Origin: Hedgehog BBS 25h/day +46-(0)18-367781 (2:206/139)* Origin: Hedgehog BBS 24h/day +46-(0)18-367781 (2:206/139) SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934 SEEN-BY: 711/955 712/407 515 517 624 628 713/888 800/1 @PATH: 206/139 0 201/505 0 200 2104 109/347 18 13/25 396/1 270/101 712/515 @PATH: 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.