writing pointer value into array

This is a discussion on writing pointer value into array within the C Programming forums, part of the General Programming Boards category; I'm reading a file to get some times into array. During debugging I found that pointer value is correct at ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    writing pointer value into array

    I'm reading a file to get some times into array. During debugging I found that pointer value is correct at the moment when I want to save it, meaning it is something xx:xx, x-es being numbers.

    I'm using
    Code:
    sscanf(pos,"%d:%d",array[n][0],array[n][1]);
    where pos is my pointer and array is int [100][2]. When it tries to execute the command I get access violation error. Why is that? Maybe some other way to put hours in array's first and minutes in second column?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You need the address of the element, not the value it contains.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444
    Either one of this works:

    Code:
    sscanf(pos,"%d:%d",&array[n][0],&array[n][1]);
    or
    Code:
    sscanf(pos,"%d:%d",array[n] + 0,array[n] + 1);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 05-29-2009, 05:48 AM
  2. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  3. sorting the matrix question..
    By transgalactic2 in forum C Programming
    Replies: 47
    Last Post: 12-22-2008, 02:17 PM
  4. Pointer with Multi-dimensional Array
    By whichet in forum C Programming
    Replies: 7
    Last Post: 11-27-2007, 11:26 PM
  5. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM

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