how to be a good C programmer?

This is a discussion on how to be a good C programmer? within the C Programming forums, part of the General Programming Boards category; Originally Posted by Adak Getting away from using parts of the language that have been found troublesome - like scanf() ...

  1. #16
    lfs addicted
    Join Date
    Nov 2007
    Posts
    49
    Quote Originally Posted by Adak View Post
    Getting away from using parts of the language that have been found troublesome - like scanf() for user input, or gets(). Maybe not the first month out, but as soon as you understand their deficiencies, switch to the better alternatives.
    Just to know... which are the alternatives?

    Isn't it good something like:

    char s[5];
    ...
    scanf("%4s",s);

  2. #17
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Almost always no. I use scanf only for little utility / fun programs.

    You want fgets(), because it takes away the "brittleness" of scanf *and* the newline char whenever you hit the enter key with entry of some value from the user.

    Scanf() is definitely "down and dirty", and has proven to be WAY down and VERY dirty, indeed.

  3. #18
    Young C n00b
    Join Date
    Jul 2006
    Posts
    59
    Vs is good to start with

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Good C++ books for a begginer
    By Rare177 in forum C++ Programming
    Replies: 13
    Last Post: 06-22-2004, 04:30 PM
  2. Good sound storage method
    By VirtualAce in forum Game Programming
    Replies: 1
    Last Post: 10-14-2003, 05:18 AM
  3. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM
  4. Opinion on GOOD digicam
    By Shadow in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-22-2003, 05:37 PM
  5. Question about atheists
    By gcn_zelda in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 08-11-2003, 11:50 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21