Thread: Syntax wars

  1. #1
    Registered User CAP's Avatar
    Join Date
    May 2002
    Posts
    179

    Syntax wars

    Ok, I have posted a couple of very small programs(I am totally new to C)and it seems that I will ask a question and people will answer it just fine(thanks guys )but then I also get like 5 other people telling me that I should not use 'goto' or I should use 'fgets' instead of 'gets'. I get what they are saying, like this line will be less confusing and such but there seems to be a long list so my question is, does anyone know of a website, have a list, or know of a book that has a list, of at least the common do's and don'ts for syntax, like something that shows you which is better in which situation and why and so, if you do please tell me.
    -Microsofts Visual C++ Introductory Kit-
    Current Projects: Learning Everything C.

    Everyone has a photographic memory, some people just don't have any film.
    ______________________________

    When was the last time you went for a colon cleansing? Because quite frankly, you're so backed up with crap that it's spilling out your mouth

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    Prelude's sig has an excelent link that should be in everyones bookmarks,

    http://www.eskimo.com/~scs/C-faq/top.html
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231

    Re: Syntax wars

    Originally posted by CAP
    Ok, I have posted a couple of very small programs(I am totally new to C)and it seems that I will ask a question and people will answer it just fine(thanks guys )but then I also get like 5 other people telling me that I should not use 'goto' or I should use 'fgets' instead of 'gets'. I get what they are saying, like this line will be less confusing and such but there seems to be a long list so my question is, does anyone know of a website, have a list, or know of a book that has a list, of at least the common do's and don'ts for syntax, like something that shows you which is better in which situation and why and so, if you do please tell me.
    Don't be put off about people pointing out problems with your code that don't relate to your original question. I always try and highlight any problem (or potential one) that I see.

    I won't lecture on gets() and goto in this thread, I'll only say that if you've got a book which you're learning from, and it starts with promoting these two statements, junk it, and get a better one.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    My personal advice, since you're big enough to admit that you're learning, is to continue to post what you have, and when someone tells you not to use something, ask them why not. Anyone who gives suggestions for improvement should be able to back it up with something more substantial than "because I said so." Besides, helping people learn C is what this place is all about. I'm guessing you already have a book on C, and even if it's not the best book, it will probably be good enough to teach you the basics, and help you to avoid the common pitfalls. Check out the faq given above, and heed well the advice you are given. You'll do fine.

    starX
    www.axisoftime.com

  5. #5
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    I look at this way; the advice others give is always worth looking into. Some of the replies I've gotten to my various questions have made me think more about which method would make more sense to use, and how to better attack any problems that might arise.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Programming is a difficult practice and you can't learn the nuances from books or websites most of the time. I've found that when I'm doing something wrong, I don't find out about it until someone more knowledgeable points it out, which is a very good reason to hang around programmers better than you are. It's highly recommended that you even offer up what you consider to be working code for double checking so that your mistakes don't go unchecked. But beware of bad or unfounded advice, not everyone who thinks they know something actually do. You should always ask a lot of questions until you are satisfied that the advice was sound and you understand why.

    -Prelude
    My best code is written with the delete key.

  7. #7
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284
    A paper some of you might find interesting to read
    http://pplab.snu.ac.kr/courses/PL200...p261-knuth.pdf

  8. #8
    Registered User TravisS's Avatar
    Join Date
    Jun 2002
    Posts
    536
    Originally posted by Prelude
    Programming is a difficult practice and you can't learn the nuances from books or websites most of the time. I've found that when I'm doing something wrong, I don't find out about it until someone more knowledgeable points it out, which is a very good reason to hang around programmers better than you are. It's highly recommended that you even offer up what you consider to be working code for double checking so that your mistakes don't go unchecked. But beware of bad or unfounded advice, not everyone who thinks they know something actually do. You should always ask a lot of questions until you are satisfied that the advice was sound and you understand why.

    -Prelude
    Agreed in full! That's why I come here. I'm certainly not the best programmer around, but at my school, just the fact I dove into Windows API meant I suddenly knew more than all the teachers...

  9. #9
    Registered User CAP's Avatar
    Join Date
    May 2002
    Posts
    179
    Thanks a lot and believe me I have no problems whatsoever with people giving advice or critism(including on spelling ). I enjoy looking at posts that not only tell me what I have done wrong and answer my questions, but will give me helpful hints so thanks to all of you people who post answers that are helpful and helping out beginners like me .
    -Microsofts Visual C++ Introductory Kit-
    Current Projects: Learning Everything C.

    Everyone has a photographic memory, some people just don't have any film.
    ______________________________

    When was the last time you went for a colon cleansing? Because quite frankly, you're so backed up with crap that it's spilling out your mouth

  10. #10
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    I've found that when I'm doing something wrong, I don't find out about it until someone more knowledgeable points it out, which is a very good reason to hang around programmers better than you are. It's highly recommended that you even offer up what you consider to be working code for double checking so that your mistakes don't go unchecked.
    Precisely.
    The world is waiting. I must leave you now.

  11. #11
    Registered User CAP's Avatar
    Join Date
    May 2002
    Posts
    179
    Going on from that whole "sticking around better programmers than you are thing" from above, why else would I be here every day?
    -Microsofts Visual C++ Introductory Kit-
    Current Projects: Learning Everything C.

    Everyone has a photographic memory, some people just don't have any film.
    ______________________________

    When was the last time you went for a colon cleansing? Because quite frankly, you're so backed up with crap that it's spilling out your mouth

  12. #12
    Registered User
    Join Date
    Jan 2002
    Posts
    16
    Originally posted by pinko_liberal
    A paper some of you might find interesting to read
    http://pplab.snu.ac.kr/courses/PL200...p261-knuth.pdf

    Great! Does anyone know where I can download a Utopia84 Compiler from?

    foffo spearjig


    PS For the non-English of you, the above is meant to be gently ironic ( and I don't mean in the Alanis Morrissette way )
    'C that?... I felt nowt' - The Original Foffo Spearjig and his hard dog. The Tube TV show, sometime in the 80's

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM