Need some help initializing a pointer.

This is a discussion on Need some help initializing a pointer. within the C Programming forums, part of the General Programming Boards category; I'm need some help initializing a pointer. Below is a segment of my code that I'm working on. The pointer ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    42

    Need some help initializing a pointer.

    I'm need some help initializing a pointer. Below is a segment of my code that I'm working on. The pointer that I need help with is subjectPtr.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    
    struct SUBJECT
    {
    	int fam;
    	int id;
    
    };
    
    typedef struct SUBJECT DATA;
    DATA *HT;
    DATA *subject_array;
    int num_elements = 0;
    int num_allocated = 0;
    
    void readInputFile(FILE *input)
    {
    	DATA *subjectPtr;
    	
    	void *temp;
    
    	while(fscanf(input,"%d\t%d", subjectPtr->fam, subjectPtr->id) != EOF)
    	{
    		.
    		.
    		.	 	
    	}
    }
    .
    .
    .

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Do you want to declare an instance of DATA, and then assign the ptr to that address? Your DATA pointer logically needs an instance of a DATA struct to point to, does it not?

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    42
    Quote Originally Posted by Adak View Post
    Do you want to declare an instance of DATA, and then assign the ptr to that address? Your DATA pointer logically needs an instance of a DATA struct to point to, does it not?
    What do you mean?

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    42
    nevermind, I got it working.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-24-2008, 11:16 AM
  2. Replies: 0
    Last Post: 03-20-2008, 08:59 AM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 04:36 AM
  4. Initializing a pointer in a class.
    By gpr1me in forum C++ Programming
    Replies: 3
    Last Post: 03-22-2006, 03:05 PM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 01:04 PM

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