Solved

i cant make casting working...

Posted on 2004-10-14
4
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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 nested-loops in the C programming language.

751 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