Core dumps

This is a discussion on Core dumps within the C Programming forums, part of the General Programming Boards category; I was just wondering... I never tried working with files and arrays, perhaps I am missing a point how to ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    99

    Core dumps

    I was just wondering... I never tried working with files and arrays, perhaps I am missing a point how to make these two work together.
    I have a file with a certain number of integers. I am opening the file, and place each integer into an array. That's how I wrote the code. Is it correct/allowable?
    Code:
    for(i = 0; i < HUNDRED; i++)
          fscanf(f_p1, "%d", array1[i]);

  2. #2
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    If array1[i] is an array of ints, you need to pass the address of the element: &(array1[i]) or simply array1+i.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    99
    THANKS! I would not even think about this! You saved my life.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enable core dumping
    By steve1_rm in forum C Programming
    Replies: 3
    Last Post: 01-21-2009, 09:41 AM
  2. buying a laptop ; intel dual core?
    By BobMcGee123 in forum A Brief History of Cprogramming.com
    Replies: 27
    Last Post: 07-30-2006, 02:28 PM
  3. program segfaults without dumping a core
    By ladar in forum C Programming
    Replies: 4
    Last Post: 04-04-2005, 11:21 AM
  4. core dump
    By kermit in forum Linux Programming
    Replies: 0
    Last Post: 08-03-2004, 06:25 PM
  5. Core dumps
    By rotis23 in forum Linux Programming
    Replies: 4
    Last Post: 06-06-2003, 10:01 AM

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