View Single Post
Old 08-14-2005, 02:50 PM   #3 (permalink)
fp_unit
mike
 
Join Date: Jan 2005
Location: Ottawa, ON
Posts: 79
fp_unit is on a distinguished road
Thanks, that helped me a while ago when I read it, sorry for the late reply

Questions:

Can I do things like this with pointers to pointers? Why or why not?

Code:
/* somefile.h. */
#ifndef SOMEFILE__
#define SOMEFILE__

typedef struct
{
    char **string_table;
    int num_strings;
} string_table;

int add_str_to_table(string_table*, const char*);

#endif
Code:
/* somefile.c */
#include "somefile.h"

int add_str_to_table(string_table * tbl, const char * str)
{
    if((strcpy(tbl[0], str)) != 0) {
        perror("add_str_to_table");
        return SOME_ERROR;
    }
    return SUCCESS;
}
I meant for this to start as a small amount of code, after I finished I might as well copy/paste it into my compiler
fp_unit is offline   Reply With Quote