Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: C - get segmentation fault right at the start of main

  1. #11
    squakie is offline Chocolate-Covered Ubuntu Beans
    Join Date
    Oct 2012
    Beans
    2,238
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: C - get segmentation fault right at the start of main

    Well, I remember struct, but it's been almost 20 years, so I am basically completely green at all of this again. Right now I'm having a heck of a time just trying to use strings - sounds stupid I suppose, but I'm really starting over here. I've read a lot of threads on the net for using strings, yet I don't seem to be able to get past the compilation stage yet. Everytime it compiles, when I run it I get segmentation faults again. Put some printf's followed by fflush of stdout so I can where it's going, but I can't make heads or tails of it. If I don't get how to use something as simple as strings then I must be lost. I'm printing off the entire thing now so I can look at it as it appears somewhere I either added or dropped a "}" as the compiler is bombing out on the last line of code.

    If I can't get these strings figured out, would it be okay to post back and see if you can help me with those? I want to keep working at it for a while first to see if I can get into my head how these things work again. At one time smart, but now oh so stupid It's amazing how 20 years can destroy a career's worth of knowledge if you stopped having to apply it (heh, I'm an old guy!).

    Thanks again!

  2. #12
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,239
    Distro
    Kubuntu

    Re: C - get segmentation fault right at the start of main

    Quote Originally Posted by squakie View Post
    It's amazing how 20 years can destroy a career's worth of knowledge if you stopped having to apply it (heh, I'm an old guy!).
    There's no need for guesswork, or employing bad practices that you may have learned many years ago. It seems to me that you should re-learn C, without any preconceptions or bad coding practices, by referring to a good book or a tutorial. Start from page 1, and work your way through the material. Don't skip a topic because you think you know it.

    Here's a link to Beej's Guide to C Programming.
    Last edited by dwhitney67; March 4th, 2014 at 11:29 AM. Reason: a better link for the guide

  3. #13
    squakie is offline Chocolate-Covered Ubuntu Beans
    Join Date
    Oct 2012
    Beans
    2,238
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: C - get segmentation fault right at the start of main

    Thanks everyone. The problem isn't solved, but everytime I've come to this forum seeking help, and making it clear that I'm starting over green, everyone seems to want to insult me by saying things like "NO! NO! NO!" or the good old fashiond "rtfm".

    In reality, it's not helping, so I'm closing the thread.

  4. #14
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,239
    Distro
    Kubuntu

    Re: C - get segmentation fault right at the start of main

    Quote Originally Posted by squakie View Post
    Thanks everyone. The problem isn't solved, but everytime I've come to this forum seeking help, and making it clear that I'm starting over green, everyone seems to want to insult me by saying things like "NO! NO! NO!" or the good old fashiond "rtfm".

    In reality, it's not helping, so I'm closing the thread.
    You are not starting from green. You have preconceived knowledge of the C programming language, and based on the information you have provided in your posts, your approach to certain aspects of the language a questionable. If you are not interested in having someone with experience teach you the language and best practices for accomplishing a goal, then why are you bothering learning C (or for that matter, anything else)... why not just retire, and enjoy the good life?

  5. #15

    Re: C - get segmentation fault right at the start of main

    OP has a specific problem he's trying to solve, described here.

    @squakie: If you're really starting over, and your goal here is to achieve exporting an address book and not to re-learn C, then may I suggest using a language other than C? You can probably learn enough Perl to solve the problem at hand in less time than it takes you to de-segfault all your C (and I don't mean that in an insulting way; avoiding segfaults in C takes a lot of care). In fact, you might find someone has solved your problem already. At the very least, you won't find it easy to run into memory issues, because Perl is memory managed.

  6. #16
    squakie is offline Chocolate-Covered Ubuntu Beans
    Join Date
    Oct 2012
    Beans
    2,238
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: C - get segmentation fault right at the start of main

    I was under the impression from the previous post that you wanted me to rtfm and figure it out from there. Can't hardly post back here when that's the case.

  7. #17
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,093
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: C - get segmentation fault right at the start of main

    Quote Originally Posted by squakie View Post
    Thanks everyone. The problem isn't solved, but everytime I've come to this forum seeking help, and making it clear that I'm starting over green, everyone seems to want to insult me by saying things like "NO! NO! NO!" or the good old fashiond "rtfm".

    In reality, it's not helping, so I'm closing the thread.
    I'm sorry I was unable to help you on this occasion. Good luck with solving your problem.

  8. #18
    squakie is offline Chocolate-Covered Ubuntu Beans
    Join Date
    Oct 2012
    Beans
    2,238
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: C - get segmentation fault right at the start of main

    Thank you! I have it "sort of" working changing one of the arrays to a string, but my parsing routine isn't working right yet. I'm afraid to post the code as I'm afraid it will just be another one of those "don't know what you're doing", when it fact I know that and that's why I'm asking for help in the first place. If I knew the answers, there'd be no sense in posting

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •