segmentation fault...

R

Ram

Hi,

please find the following snippet code:

typedef struct {
int mode;
int uid;
int gid;
char prefix[MAX_NAME_LENGTH];
} config_objects;

config_objects *config_rules = NULL;

char temp_buf[1024];

const char delimiters[] = ":";


//temp_buff contains--> 00770:1000:2001:"cache"


token = strtok (temp_buf, delimiters);
config_rules->mode = atoi(token); --> segmentation fault??

Can any one please explain, why i am getting segfault here?

Thanks in advance!
-Ram
 
L

luserXtrog

Hi,

 please find the following snippet code:

typedef struct  {
    int mode;
    int uid;
    int gid;
    char prefix[MAX_NAME_LENGTH];

} config_objects;

config_objects *config_rules =  NULL;

char temp_buf[1024];

const char delimiters[] = ":";

//temp_buff contains--> 00770:1000:2001:"cache"

         token = strtok (temp_buf, delimiters);
         config_rules->mode = atoi(token); --> segmentation fault??

Can any one please explain, why i am getting segfault here?

If config_rules is NULL, then config_rules->mode is not a valid
storage location. Perhaps you should allocate a structure for
config_rules to point at.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top