Solved

i cant make casting working...

Posted on 2004-10-14
4
215 Views
Last Modified: 2010-04-15

      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
0
Comment
Question by:Carl3003
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
efn earned 25 total points
ID: 12315389
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
 

Author Comment

by:Carl3003
ID: 12315503
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
 
LVL 4

Assisted Solution

by:pankajtiwary
pankajtiwary earned 25 total points
ID: 12315555
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
 

Author Comment

by:Carl3003
ID: 12315757
thanks but i made it working..:-)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now