Why core dump??

This is a discussion on Why core dump?? within the C++ Programming forums, part of the General Programming Boards category; I cant figure out why I continue to get a core dump with this function. I'm trying to print out ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    27

    Why core dump??

    I cant figure out why I continue to get a core dump with this function. I'm trying to print out the numbers 3, 5, 7, 9, 11, 13

    _num, field_size, and num_per_line are all equal to 6 when I call the function

    Code:
    void Vect::tellsome( ostream & out, int field_size, int num_per_line)
    {
      for(int i = 0; i < _num; ++i)
      {
        if((i % num_per_line) == 0)
        {
          out << endl;
        }
        out << setw(field_size) << _data[i];
      }
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    > I cant figure out why I continue to get a core dump with this function
    Probably because the problem is really somewhere else, and here is just where you get to notice that there is a problem.
    We really need the whole program (or a complete sub-program which also crashes) to comment in any meaningful way.

    Except to say that you need to check every pointer, and every new call in your code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. having a core dump
    By justins in forum C Programming
    Replies: 6
    Last Post: 05-21-2008, 12:00 PM
  2. STL vector core dump
    By creativeinspira in forum C++ Programming
    Replies: 9
    Last Post: 07-22-2007, 04:49 PM
  3. Core Dump in While()
    By KrepNatas in forum C Programming
    Replies: 5
    Last Post: 05-17-2005, 11:15 AM
  4. core dump
    By kermit in forum Linux Programming
    Replies: 0
    Last Post: 08-03-2004, 06:25 PM
  5. segmentation core dump - need help
    By knight101 in forum C++ Programming
    Replies: 1
    Last Post: 11-26-2001, 03:43 PM

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