Re: [SLUG] evil C question! AAAGGHH!! help !!

From: Glen (gurensan@tampabay.rr.com)
Date: Tue Jun 19 2001 - 23:47:04 EDT


In another function, parse_comm_config():

<snip>
        if(strstr(line, "PORT")){
                equal_ptr = strchr(line, '=');
                comm_settings.PORT = ++equal_ptr;
                comm_settings.PORT[strlen(comm_settings.PORT)-1] = '\0';
                equal_ptr = NULL;
                continue;
        }
<snip>

        line[] is a char * to a line of text read in from a config file with
fgets(). It's read in just fine here, as shown when I print it with fprintf()
from the calling function after this one returns. The char *equal_ptr is
nullified after each line is parsed for safety's sake (i.e. I did a stupid
oops later on in the code with this).

        Glen

On Tuesday 19 June 2001 21:45, you wrote:
> where and how do you set the PORT character pointer?
>
> Ed.
>
> Glen wrote:
> > Dear list,
> >
> > I have been having trouble with something very odd. Here is my
> > global struct:
> >
> > struct{
> > int BAUD;
> > int PARITY;
> > int DATA;
> > int STOP;
> > int FLOW;
> > int FLAGS;
> > char *PORT;
> > }comm_settings;
> >
> > When I call a certain function, the char * variable in the struct gets
> > killed. Observe:
<snip>



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:23:13 EDT