Thread: poniters will kill me

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by BEN10 View Post
    I also devote time in thinking but to no avail. If I would have not joined this forum I would be still using void main(). Seriously.
    To be fair, there's no amount of thinking that will allow you to "fix" void main -- that's just a fact that you have to know (either in terms of what C expects or how the operating system interacts with your program or some equivalent).

    I am also not Elysia, but one of the things that helped (in retrospect, it didn't seem like it at the time) was the fact that my data structures class was completely computer-free: no programs to turn in or even write, just pictures of lists and trees and queues and I think we did heaps, completely in pseudocode with (crappy, because we were sophomores) proofs of correctness for the algorithms. So I will second MK's suggestion of thinking about linked lists and how to make them.

  2. #17
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I tried this on my old Turbo C - it ran it 3 times through - no problems.

    *THEN* I saved it as a file, and tried to run it again - fatal error every time "Illegal initialization..." Tried it six times after it started giving the fatal errors, but it never would allow it to compile, again.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by BEN10 View Post
    For how many years are you programming? And what approach did you take for difficult to understand topics specially pointers?
    In total, I've been programming for like 14 years.
    I've been programming C++ for like 10-12 years perhaps.
    I've never really had much problems understanding pointers. Ever since reading the basics of them in my first C++ book, I've known them. My mind suits well to these kinds of things.

    It's basically just three things:
    One variable to store a memory address (pointers).
    A way to take the address of a variable (address-of operator &).
    A way to read or store something at an address (dereference operator *).
    The rest is just logical thinking.

    I also devote time in thinking but to no avail. If I would have not joined this forum I would be still using void main(). Seriously.
    Things get easier with more experience in the matter. And to get more experience you usually ask questions and experiment with it.
    So you are doing alright and is on the right track. Don't worry.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by brewbuck View Post
    instructions to produce those addresses can be generated at compile time.
    Initialization requires the result to be available at compile time, not just that the instructions needed to compute it can be done, no?

  5. #20
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by Elysia View Post
    In total, I've been programming for like 14 years.
    I've been programming C++ for like 10-12 years perhaps.
    I've never really had much problems understanding pointers. Ever since reading the basics of them in my first C++ book, I've known them. My mind suits well to these kinds of things.

    It's basically just three things:
    One variable to store a memory address (pointers).
    A way to take the address of a variable (address-of operator &).
    A way to read or store something at an address (dereference operator *).
    The rest is just logical thinking.


    Things get easier with more experience in the matter. And to get more experience you usually ask questions and experiment with it.
    So you are doing alright and is on the right track. Don't worry.
    Thanks Elysia for your morale boosting reply. In comparison of time I must say I'm very much of a newbie coz I've been in the field of programming for about 1 year.
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  6. #21
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Yes, 1 year is not enough so don't beat yourself up. Sometimes I think C is not a good starter language as an into to computer science, as it used to be called.

    The way I learned programming 38 years ago (holy crap!) in high school was to start with binary representation (on the backboard), then fundamental concepts of memory and gates. Then BASIC language... Then I picked up the Operator's Manual for the mini we were using and ventured into machine language on my own. In university we covered a host of languages: COBOL, ALGOL, SNOBOL, LISP, PL1, FORTRAN. Note: no "C" existed in the mid 70s that I was aware of.

    "C" came much later for me.... I learned it from the K&R book. My background in assembler and basic concepts really helped. My favorite was APL - another self-taught language.

    I think people starting out in "C" have too many concepts to master all at once. The language plays so precariously close to machine-language ideas that it is sometimes referred to as a macro assembler. Unless you also played with hardware chips, interfacing, micro-controllers as a hobby, diving straight into "C" has to take up the slack. My guess is that's why you feel you're stumbling along at a pace that seems disappointing to you. But to your credit, you have a lot of resources at your fingertips and ultimately if you continue to be persistent, you'd out pace the learning speed I went through.

    And I'm still learning!

    P.S. From what I've seen, you're already helping a lot of newbies with your helpful posts. I bet they're thinking you're a genius too! It's all relative.
    Last edited by nonoob; 07-07-2009 at 03:12 PM.

  7. #22
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    nonoob: I agree completely: C is not a good beginner language, for the reasons you suggest: It is very low level [sure there are some really high-level functions in there].

    The key here is that pointers aren't that easy to understand. At 1 year into learning C, I didn't know how much of pointers I knew. But then I knew several variants of assembler (Z80, 6502 and PDP-11) before I learned any C.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #23
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Yes, exactly. I learned my way around computers by fiddling with the front panel of a HP2100A mini computer with 8K words (equivalent 16K bytes) of memory. Addresses, indirect addressing, all became abundantly clear in a hurry. So they're called pointers now.

    Any other languages I've seen that even come close to making things horrible were PL/C (PL1 subset), Algol, TAL (Tandem Application Language) - they had concepts of pass-by-value vs. pass-by-reference and associated pointer syntax. But they weren't as kludgy as "C". For example, they didn't demand that you change all the variable prefixes to "*" if you decide to make a function's parameter call-by-reference. Their compilers simply did the conversion for you. Unlike in "C" where at times you'd swear you're doing more of the compiler's work than you should need to.

    Some languages don't even confuse the issue with addresses. Pass-by-reference is automatic (or assumed, or conceptually so, or optimized to that effect to prevent redundant memory copying as needed). They get along perfectly well without ever putting the programmer through address/pointer headaches. And yes. some can pass variables, arrays, and higher concepts without hiccup. Nary a dot or an asterisk anywhere!
    Last edited by nonoob; 07-07-2009 at 03:40 PM.

  9. #24
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Hmmmm......Now the way I see it's not easy to become a professional.
    @nonoob,matsp
    Thanks for sharing your experiences.
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  10. #25
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    I think it's relatively easy. Just write some code for someone else and get paid. Voila! You're a pro. In grade 12 another student who wanted me to write his calendar generator for him offered me money. I was almost turned into a "professional" contract programmer then. LOL.

    Heck even script kiddies that can kludge together HTML are called developers/programmers these days and make more than me.

  11. #26
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> In grade 12 another student who wanted me to write his calendar generator for him offered me money. I was almost turned into a "professional" contract programmer then. LOL.

    I started back in June or July of 2001. A friend of mine asked if I knew how to "get the computer to do" something (the actual program escapes me now). I didn't, of course, but it got me wondering about how all that worked in the first place. I had only been using a computer for about two years or so at that point and really had no idea at all what made them tick. So I went to the local bookstore to check out their programming books to see what language I should learn first. I looked through a good number of books, but none really interested me much - they all seemed to be either too complicated or too simple! Then I stumbled across a book called "C, A Software Engineering Approach". I loved everything about it; it was bound like a Boy Scout manual and contained page after page of gritty, straightforward advice. I was sold.

    That same week I joined an online forum called Cprogramming.com, and for quite a while thereafter pestered a guy named Salem (he may have been going by Stee at the time - not sure though), who was infinitely gracious toward my ignorance, until I learned the basics. I even remember my first "program': it was basically a function to strip stray characters from a numerical input string, so that you could convert say "foo2.bar2.71baz82" into "2.7182" (yeah, like that's even useful). Since then I've been programming continuously, and have even picked up a number of other languages along the way. But yeah, it's not the easiest field to study, and generally takes a number of years (maybe 5 - 10) before you actually excel at it. It's been an enjoyable experience though - I wouldn't trade it for anything.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to kill a dragon with various programming languages
    By g4j31a5 in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 10-01-2007, 12:13 PM
  2. Kill Signal Number? - Help !
    By brett in forum C Programming
    Replies: 5
    Last Post: 06-20-2007, 03:39 AM
  3. Can anyone help me with the Kill command in C please?!!!
    By jon20 in forum Linux Programming
    Replies: 3
    Last Post: 04-07-2002, 10:37 AM