file query

This is a discussion on file query within the C Programming forums, part of the General Programming Boards category; Hey ,I was trying to design a code to handle file.It consists of character nodes.Line nodes that include character nodes. ...

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

    file query

    Hey ,I was trying to design a code to handle file.It consists of character nodes.Line nodes that include character nodes. and a file that includes line node .

    I wrote this code below,but it won't work.Wonder if some-one can help spot the error.

    Code:
    typedef struct CharacterNode {
    	struct CharacterNode *nextCharacterNode;
    	char data;
    }characterNode;
    
    typedef struct LineNode {
    	struct CharacterNode *characterNode;
    	struct LineNode *nextLineNode;
    }lineNode;
    
    typedef struct fileADT {
    	struct LineNode *lineNode;
    	int size;
    }FileADT;
    
    
    void initFileADT(FileADT *file) {
    	
        file->lineNode = NULL;
        file->size=0;
    }
    
    
    int main(int argc, char *argv[]) {
    
    	FileADT *a;
    	a=NULL;
    	initFileADT(a);
    	
    	
        return EXIT_SUCCESS;
    }
    thanx ppl

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    You have to allocate memory for the pointer. By the time you're initializing the variables, it's just a NULL pointer. If you don't know how, look into malloc().
    Sent from my iPadŽ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  2. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  3. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 09:57 AM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

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