Array manipulation Question

This is a discussion on Array manipulation Question within the C++ Programming forums, part of the General Programming Boards category; ok so it works now except one thing..... The array before sorting: 4 3 2 1 The array after sorting: ...

  1. #16
    Registered User
    Join Date
    Mar 2008
    Posts
    25
    ok so it works now except one thing.....

    The array before sorting: 4 3 2 1
    The array after sorting: -708361232 1 2 3

    trying to figure it out.... can anyone else spot it?

  2. #17
    Registered User
    Join Date
    Mar 2008
    Posts
    25
    they said C++.....

  3. #18
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    They were wrong. VLAs are in C99 or a GCC-specific extension, but not C++.

    Looks like an out-of-bounds memory access, and off-by-one error.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #19
    Registered User
    Join Date
    Mar 2008
    Posts
    25
    well if it is c99 why is it working?.... ya i assumed it was an out of bounds.... just struggling to find it....

  5. #20
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,648
    well if it is c99 why is it working?
    It is a g++ extension ported from gcc's support for C99. You can disable it with the -pedantic option (and/or -ansi, I am not too sure).
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #21
    Registered User
    Join Date
    Mar 2008
    Posts
    25
    well figured out the out of bounds error..... but the algorithm doesn't seem to work.... so gotta go figure that out :-P

    thanks!

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic Mutli dimensional Array question.
    By fatdunky in forum C Programming
    Replies: 6
    Last Post: 02-22-2006, 06:07 PM
  2. Array of Structs question
    By WaterNut in forum C++ Programming
    Replies: 10
    Last Post: 07-02-2004, 02:58 PM
  3. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 12:01 AM
  4. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 11:09 AM
  5. Create Array size Question
    By popohoma in forum C++ Programming
    Replies: 3
    Last Post: 11-04-2002, 02:04 AM

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