Solved

i cant make casting working...

Posted on 2004-10-14
4
226 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

New My Cloud Pro Series - organize everything!

With space to keep virtually everything, the My Cloud Pro Series offers your team the network storage to edit, save and share production files from anywhere with an internet connection. Compatible with both Mac and PC, you're able to protect your content regardless of OS.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

911 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

28 Experts available now in Live!

Get 1:1 Help Now