help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to test memory allocation with new ?


From: jjleto
Subject: Re: How to test memory allocation with new ?
Date: Mon, 01 Nov 2004 14:38:52 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; fr-FR; rv:1.7.3) Gecko/20040924 Debian/1.7.3-1ubuntu1

char *pp = new char[...];

Thanks, the segmentation fault was actually for the reason you gave.

Nevertheless, I still have an error when running this program ("give up" but not a segfault)

        #include <iostream>
        using namespace std;

        int main()
        {
                int n = 0x7FFFFFFF;
                char *pp = new char[n];
                if ( pp != NULL ) {
                        pp[0] = 0;
                        pp[n-1] = 0;
                        cout << "OK" << endl;
                } else {
                        cout << "FAILED" << endl;
                }
        }

How do I test memory allocation with new ?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]