Chris Gordon-Smith
9/30/2008 11:04:00 PM
Scoots wrote:
>
>
> On Sep 30, 5:54 pm, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
>> Scoots wrote:
>> > Okay, I have a really simple program that illustrates a problem I'm
>> > having.
>>
>> > I'm using VC++6.0 (yes, an upgrade is in the works). Anywho, I have
>> > this problem:
>>
>> > int main (int argc, char * argv[])
>> > {
>> > int iNumFuncs = 1;
>> > int * hey = new int [iNumFuncs]; <<--Segfaults. ??????
>> > return 0;
>> > }
>>
>> > Is my installation just gone out the window, or am I so incredibly
>> > tired that I can't even do a dynamic allocation anymore?
>>
>> The code seems OK (the memory leak is beside the point, I guess). If
>> you need your question answered with VC++ in mind, then you need to ask
>> it in the VC++ newsgroup, though: microsoft.public.vc.language.
>>
>> There can be some compiler specific settings that are off-topic here,
>> try the other newsgroup and see what they say...
>>
>> V
>> --
>> Please remove capital 'A's when replying by e-mail
>> I do not respond to top-posted replies, please don't ask- Hide quoted
>> text -
>>
>> - Show quoted text -
>
> Well, the memory leak is kinda irrelevant, I just commented out the
> few hundred other lines in the code and didn't bother posting them
> here. There IS a delete[], it's just commented out.
>
> And I didn't think this was a VC++ question in particular, since I'm
> not using a single call to anything relating to VC++. What I posted
> should be standard c++ in it's entirety.
>
> My question, is what can be causing that. And I believe your answer
> was: "Compiler."
>
> Thanks,
> ~Scoots.
>
> (P.S. I appologize for any seeming rudeness, it is unintentional.)
I don't use arrays much, so the syntax is a bit unfamiliar to me. However,
its working fine here with gcc version 4.3.1 on OpenSUSE 11.0
int main (int argc, char * argv[])
{
int iNumFuncs = 1;
int * hey = new int [iNumFuncs]; //Â <<--Segfaults. Â ??????
hey[0] = 99;
cout << "hey = " << hey << " hey[0] = " << hey[0] << endl;
return 0;
}
Output: hey = 0x804b008 hey[0] = 99
Chris Gordon-Smith
www.simsoup.info