Thread: simple pointer and struct question

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by CommonTater View Post
    I think tha'ts arguable at best Elysia. By and large I like your posts, you are one of the most helpful people here and that can only be a good thing.

    I agree it may hurt readability for those not accustomed to it but what do you do when you have to work with it day in day out? You get used to it and that would be the issue here; what you get used to.

    The windows tactic is to define a struct and pointer together, prefixing the pointer with either P or LP according to rules not entirely clear. If you ever do windows programming --and most of us will-- you do need to be comfortable with the notations.

    So... I wouldn't expound on one while panning the other... in all truth, we need to know both.
    I have worked with Windows Programming, so I do know. I am accustomed to it, yet I don't like it.
    Anyway, the point is, that you are right in a sense. You do have to get used to it, but that doesn't mean you should blindly follow that style yourself.
    Just as you learn to put your own style to use. As would you do with this!
    I really would like newbies not to use pointer typedefs until they experienced enough. I don't want to teach them bad habits when they start out.
    Learning to interpret others styles is not the same as adopting their styles. That's all I want to point out on that subject.

    Quote Originally Posted by laserlight View Post
    I think that it really depends on the situation; I don't see how a typedef of an opaque pointer type would be a bad idea. (And in a smarter version of the program, StupidList might be just such a pointer type )
    There might probably be some use somewhere, but programmers will find those in time. For the time being--and especially in small programs like this--they serve no use other use than to obfuscate. At least, such is my opinion. And I clearly want the newbies to understand this.
    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.

  2. #17
    Registered User
    Join Date
    Jul 2010
    Location
    Oklahoma
    Posts
    107
    Elysia,

    Nicely done. Thank you for such a complete response. I do truly respect your opinion and your style....

    CommonTater,

    The OP indicated that they were a beginner ("...very new to C..."), the declaration just seemed to over complicate the issue...which I understood to be with the pointer data type, rather than the extravagant declaration of pointer types -- which in opinion obscures their handling.

    I've seen and worked with quite a bit of the Windows API since 3.1, and I thought it not surprising that it was so frequently unstable. In fact, in order to avoid bone-headed errors, I would avoid the typedef-ed declarations all together and type the name of the data type if there were any issues with it at all. Especially, when I was module testing or debugging....

    Of course, I realize that experience and proficiency brought with them some finesse, it just seemed to distract the point from the problem the OP had is all. I didn't mean to under-mind any one's reply, I just thought it odd, so I asked. If the Windows crew wishes for my opinion, I will share such a sentiment with them...of course, I think I may have missed the boat on that one .

    By the way, thank you for the replies, again.

    Best Regards,

    New Ink -- Henry
    Kept the text books....
    Went interdisciplinary after college....
    Still looking for a real job since 2005....

    During the interim, I may be reached at ELance, vWorker, FreeLancer, oDesk and WyzAnt.

  3. #18
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Elysia, laserlight and new ink....

    Thanks for your thoughtful replies. It certainly is interesting how different styles and ideas evolve around these things.

    In my own defense... I use the "windows way" as a means of having consistency throughout my code. If I were to work on a project that did things differently, I'd probably try to adapt to that as well... as I pointed out in another message, the thing is that you're going to have to come back in 5 years and still read your own code...

    Cheery day to all!

  4. #19
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    Quote Originally Posted by Bayint Naung View Post
    Code:
        list->format_name = malloc(32);
    
        list->format_name = "hello";
    Well, this is a memory leak. I don't think someone who write code like this are not really comfortable with pointers...
    Just so you guys know, that was a mistake. I woudn't actually write code like that. It's probably too late to redeem myself now though haha.

  5. #20
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Syscal View Post
    Just so you guys know, that was a mistake. I woudn't actually write code like that. It's probably too late to redeem myself now though haha.
    Aye laddy... the drogues be upon ya!

    Seriously though... we all make mistakes. The big secret in life is to not make the same mistake twice.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help assignment due tomorrow
    By wildiv in forum C Programming
    Replies: 6
    Last Post: 01-27-2010, 08:38 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 01:34 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM