Focus on these four key concepts when first teaching C to help students with previous programing experiences transition from higher-level languages such as Python.

Like(341 Likes)
  • Ensuring students walk away fully understanding these four concepts is vital for success in a first C course and in future computer science courses.

1. .h and .c files, Multiple File Programs

  • You want students to be able to write a program that use multiple files.
  • You want students to learn C’s way of specifying interfaces and implementations, what goes in a .h and a .c file, what "extern" and "static" mean, and how .h and .c files are used in the compilation process.

2. Pointers, dynamic memory allocation.

  • malloc (and free): how to dynamically allocate and deallocate program heap memory is a vital concept.
  • Explicit memory management is new material for students who only have experience in Python.
  • Drawing the execution stack and the heap can help students understand pointer and non-pointer types, C style "pass-by-reference", and dynamic heap memory allocation (and free’ing).

3. String Processing

  • After working in Python, students become used to rich support for string.
  • s = s1 + s2 causes confusion when it no longer magically concatenates strings.
  • Strings in C, and using the C string library, are difficult because students have to focus on memory.
  • Doing some drawing of strings as an array of characters (with the space for the terminating ‘\0’) can help them see what they need to allocate and pass to C string library functions.

4. Types

  • For students coming from python, thinking about type and about operators on specific types may be something that they have been able to avoid. Stressing type and values of expressions when teaching python can help make the transition to languages like C a bit easier for them.
  • Drawing pictures of the difference between pointer and non-pointer variables can help with student’s understanding of how to use variables of different types.

More about this tip

External Source

Interview with Tia Newhall