msvc++ 6 wont allow declaring arrays in main() function

This is a discussion on msvc++ 6 wont allow declaring arrays in main() function within the C++ Programming forums, part of the General Programming Boards category; anyone know why that is it works fine in Dev C++ i can still declare them as globals...

  1. #1
    Bobish
    Guest

    msvc++ 6 wont allow declaring arrays in main() function

    anyone know why that is it works fine in Dev C++

    i can still declare them as globals

  2. #2
    Unregistered
    Guest
    it should be a simple matter to declare and array.

    int main( )
    {
    char array[ 20 ];

    return 0;
    }

    it wont let you do this??

  3. #3
    Señor Member
    Join Date
    Jan 2002
    Posts
    561
    Yeah it should work. I use dev, turbo, and msvc and I can declare arrays in main in all of them. Check your syntax.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Post some code so we can see what you're doing wrong.

    -Prelude
    My best code is written with the delete key.

  5. #5
    Bobish
    Guest
    okay it was because the array was to big apperntly there is a lower limit on array size in msvc++ for global variables. It dosn't really matter though i was just wonderning why that was.

  6. #6
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    You're probably overflowing the stack.

  7. #7
    bobish
    Guest
    i just wonder why it only happens in those specific conditions

  8. #8
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    >i just wonder why it only happens in those specific conditions

    What conditions? Post some code and I'm sure someone will be able to give a definitive answer instead of having to be vague. If it is overflowing the stack (which I suspect it is, because the linker used by Dev C++ sets up a larger default stack), then if you really need a large local array you can use linker settings to make it possible.

    However, I don't think you're making sense with -

    there is a lower limit on array size in msvc++ for global variables
    as there's no lower limit on globally allocated stuff, so again post the code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Replies: 4
    Last Post: 11-23-2003, 07:15 AM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 01:04 PM
  5. Returning arrays from function to main
    By musayume in forum C Programming
    Replies: 3
    Last Post: 05-12-2003, 05:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21