• C

i cant make casting working...


      char dir_str[100];
                dir_str[0] = '\0';
      strcat(dir_str, "/dev/");
      strcat(dir_str, (char*)utbufp->ut_line);  // right here i get error mesg..

The code would  not work even if i replace   strcat(dir_str, (char*)utbufp->ut_line);   with
strcat(dir_str, utbufp->ut_line);  
Thanks in advance
Carl3003Asked:
Who is Participating?
 
efnConnect With a Mentor Commented:
What is the type of utbufp->ut_line?  Is this a compile-time message or a run-time message?  What does the message say?
0
 
Carl3003Author Commented:
Segmentation Fault (core dumped)

struct utmp {
        char ut_user[8];                /* User login name */
        char ut_id[4];                  /* /etc/inittab id(usually line #) */
        char ut_line[12];               /* device name (console, lnxx) */
        short ut_pid;                   /* short for compat. - process id */
        short ut_type;                  /* type of entry */
        struct exit_status ut_exit;     /* The exit status of a process */
                                        /* marked as DEAD_PROCESS. */
        time_t ut_time;                 /* time entry was made */
};

0
 
pankajtiwaryConnect With a Mentor Commented:
The error says, its a segmentation voilation. Can you please post the parts of the code where you are assigning the values to the structure. That would be helpful.
0
 
Carl3003Author Commented:
thanks but i made it working..:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.