#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    1
    Rep Power
    0

    Do I need general knowledge in programming to take a C Programming class?


    I am looking to take a class in C programming and have no former knowledge of programming. Is this a bad idea? :cool:
  2. #2
  3. Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    New Springfield, OH
    Posts
    1,214
    Rep Power
    1469
    This really depends on the course. I'd talk to whomever is giving it.

    Generally speaking I would say no. C is usually thought of as a beginner language (although it is extremely powerful). The reason is that a lot of other languages are based upon it.

    A good C course is going to take you through all of the requisites.
    Don't like me? Click it.

    Scripting problems? Windows questions? Ask the Windows Guru!

    Stay up to date with all of my latest content. Follow me on Twitter!

    Help us help you! Post your exact error message with these easy tips!
  4. #3
  5. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,376
    Rep Power
    1871
    I would caution against learning C as a first language if you have no prior programming experience.

    First, it is a low level language, so you have to do quite a lot of work to actually get anything done. It will be a while before you write your first program to do what you want (as opposed to merely following the lesson plan and examples). If you have the kind of personality that needs an early reward "buzz" for success, then you might need to consider another language.

    Secondly, the syntax is extremely permissive. Meaning you can easily slip from legal code to illegal code in just a few characters, and the result will still compile. The problem is, such flexible syntax can also be legal code depending on the context in which it is used.

    Three, there is no run-time memory protection. What rules there are are randomly enforced.
    Take this example.
    Code:
    int array[10];
    for ( i = 0 ; i <= 10 ; i++ ) array[i] = 0;
    Now anyone proficient knows this is an array overrun.
    90% of the time, this will appear to run normally (luring you into a false sense of success).
    90% of the remaining time, the program will crash in some unrelated area of the code, when it finds it's memory, which just happened to be after the array, has been trashed with a zero.
    On vanishingly few occasions, you would actually get a run-time error on the actual errant assignment.
    Now tools such as lint can be used to spot many such problems, but these are seldom available to students.

    The real killer is that the smaller the program (typical for students), the more outrageous you can be with memory errors and still get away with it and have a program that runs. In very large programs, almost all memory errors will eventually be caught with a random crash. The problem for the student, the mistake has to be unlearnt.


    How to spot a bad tutor / book.
    Code:
    #include <conio.h>
    void main ( ) {
      char *buff;
      gets(buff);
      fflush(stdin);
      printf(buff);
      getch();
    }
    - conio.h is an obsolete header file.
    - main always written as 'int main', not 'void main'.
    - buff is an uninitialised pointer (not specifically illegal in itself).
    - gets() is the worlds most dangerous function. For good reason, the current C standard makes gets() obsolete. Passing an uninitialised pointer to gets() is totally broken.
    - fflush() is for output streams (or update streams following a write). It has no meaning on input streams. It might work for you, but it won't work for me.
    - printf is fine, when used correctly. This example is not correct usage. Though it will appear to work just fine until the user types in a % character.
    - getch() is a non-portable function. A typical question from people who learnt a 'dialect of c' is "how do I use getch on my new compiler?".

    So if you see conio.h, void main, gets() and fflush(stdin), then you have the wrong book / tutor.

    The only reason to ever mention gets() should be to tell you to never use gets(). Any other use is bad information.



    If C were a car, it would be an old Ferrari.
    Absolutely fantastic to drive when you know how, but it's not the car you want for learning to drive. You'll be off the road and in the hedge at the first corner if you're not careful.


    A good beginner language would be something like Python.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  6. #4
  7. Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    New Springfield, OH
    Posts
    1,214
    Rep Power
    1469
    I absolutely agree with your assessment, Salem. However, those are precisely reasons I like C as a beginning language. It forces you to learn to program properly. Most other languages work very nicely while allowing you to develop incredibly poor habits.

    Suffice to say that I do agree it's not a road to be taken by the feint of heart.
    Don't like me? Click it.

    Scripting problems? Windows questions? Ask the Windows Guru!

    Stay up to date with all of my latest content. Follow me on Twitter!

    Help us help you! Post your exact error message with these easy tips!
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,837
    Rep Power
    480
    int main(void) {

    /*
    is a lie. The start-up code passes parameters to main, and you don't control that. The c implementations I'm familiar with have the caller take care of the arguments they put on the stack (or whatever the argument passing mechanism is). The lie doesn't matter.
    */

    return STATUS;
    }

    /* the return statement also is a lie---at least in linux. (per my understanding) return from main is converted to
    exit(STATUS);
    */
    [code]Code tags[/code] are essential for python code and Makefiles!
  10. #6
  11. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1802
    Originally Posted by kathyrollo
    Sorry for the questions guys. Curious, curious.
    Questions are fine; that is what teh forum is for, however you seem to be asking your own questions on a thread started by someone else on a different subject. It is hardly fair on the OP whose question is now being ignored in favour of yours.

    Regarding the original question, the syllabus and prerequisites of any course will vary. Any course of any quality will clearly state the prerequisites in the prospectus. Simple as that.

    That said, while at one time C was the primary language for desktop application development (because most OS APIs are C), this is no longer the case. With the advent of the GUI, application development has largely been the domain of object oriented languages, such as C++ and C# (primarily on Windows), Objective-C (primarily on OSX), and Java (the preferred language on Android). Only Linux perhaps is still reasonably well supported by C application frameworks (GNOME), but even there most other major frameworks are OO. Outside of systems level code, embedded systems and legacy systems maintenance I would suggest that C is becoming increasingly irrelevant, so if the desire to take this course is for career development, you might want to look a an alternative. On the other hand, C is a simple language and can be learned quickly, and is a good language to learn the fundamentals, C++ is larger and more complex in its entirety but essentially contains all of C.
  12. #7
  13. Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    New Springfield, OH
    Posts
    1,214
    Rep Power
    1469
    Originally Posted by clifford
    Questions are fine; that is what teh forum is for, however you seem to be asking your own questions on a thread started by someone else on a different subject. It is hardly fair on the OP whose question is now being ignored in favour of yours.
    Agreed. Thread split.
    Don't like me? Click it.

    Scripting problems? Windows questions? Ask the Windows Guru!

    Stay up to date with all of my latest content. Follow me on Twitter!

    Help us help you! Post your exact error message with these easy tips!

IMN logo majestic logo threadwatch logo seochat tools logo