please help (novice)

From: ranger (sgrine_at_msn.com)
Date: 11/20/04


Date: 20 Nov 2004 11:22:23 -0800

Hi,

I'm a beginner with C++, studying on my own from a book and I've
encoutered quite some problems.. If possible, someone out there might
help me out..

The problem is the following.. I've tried to create a couple of string
class/functions.. and they do compile.. but when I run them.. windows
suddenly reports an error.. As I'm just a beginner in C++, with noone
around me to help.. I'd appreciate if someone might help me out!

The simple (reduced) code is the following:

#include <iostream.h>
#include <stdio.h>
#include <stdlib.h> // for EXIT_SUCCESS
#include <string.h>

class string{
public:
        string(void){characters = 0; pt = NULL;}
        string(char *s);
private:
        int characters;
        char *pt;
};

string::string(char *s){
        characters = strlen(s);
        pt = new char[characters];
        if (pt = NULL){
                cerr << "Failed to allocate string.\n";
                exit(EXIT_FAILURE);
        }
        memcpy(pt, s, characters);
}

void main()
{
        string s1("My first string");
}

If you compile it, you'll see that the compiler doesn't report any
error.. but when running it, you'll see that you suddenly get a
windows error report..

Does someone know what the source of this fault might be and what to
change about the code above?

Thanks!!



Relevant Pages

  • Re: Error Message when running report
    ... did you Compile your code? ... did you change the ControlSource and Name properties on the report to match the columnname in your query? ... You either have a bad reference in your code, a calculated field in the ...
    (microsoft.public.access.reports)
  • Re: Error Message when running report
    ... Sorry there was a typo in my re-typing of the error message. ... The query runs and provides the correct data with no ... report, or the query that the report is based on. ... Whenever you change code or references, your should always compile ...
    (microsoft.public.access.reports)
  • Re: Lebans or other Raw Binary Image Storage
    ... converted mdb does compile. ... I've not needed to do much with images before. ... > because my A2K version does not contain the converted Form to Report you ... > compile it and test in A97. ...
    (microsoft.public.access.formscoding)
  • Re: Lebans or other Raw Binary Image Storage
    ... converted mdb does compile. ... I've not needed to do much with images before. ... > because my A2K version does not contain the converted Form to Report you ... > compile it and test in A97. ...
    (microsoft.public.access.modulesdaovba)
  • Re: A97 closes down each time I open a particular report. Anyone know the meaning of this?
    ... > any problem in some code upon which the report depends; ... The reason you have to decompile is that the corruption is sometimes ... COMPILE ON DEMAND, because it leads to extra compiling that is not ...
    (comp.databases.ms-access)