student@ubuntu:~$
Topic Week 4 3 min overview

Java to C

The paradigm shift from managed-language CSCD 210 to raw-memory C, and every first-day mechanic you need for Lab 1

In a nutshell

In CSCD 210 you wrote Java and ran it on the JVM. The JVM handled memory, bounds checking, string objects, exception unwinding, and the compile-link-load dance. C strips all of that away. You write source, run gcc, and the operating system loads the resulting native binary directly. This topic introduces the language, the compile command, the data types, formatted I/O with printf and scanf, and how C strings work. Everything Lab 1 grades lives here.

Why it matters

Every class that has CSCD 240 as a prerequisite (CSCD 260 Architecture, CSCD 330 Networks, CSCD 340 Operating Systems) assumes you can read and write C at this level. Every CTF challenge that hands you a binary starts from “what would the C source for this have looked like?” And almost every historic memory-safety CVE (Heartbleed, Baron Samedit, the WhatsApp GIF overflow) is a C bug that a programmer with the habits from this week would not have written. The week is not just a Java-to-C glossary. It is the habits that replace the safety net Java gave you.

Key takeaways

  • Compile command. gcc lab1.c -Wall -Wextra -pedantic -std=c90 -o lab1. Copy it exactly; zero warnings is the goal, not a nice-to-have.
  • C90 discipline. Every variable declaration goes at the top of its block. /* ... */ comments only. Counter at the top of main, then for (i = 0; ...).
  • Four scanf patterns cover every input in Lab 1: %d with &, %lf with &, %s without &, " %c" with a leading space.
  • printf never adds a newline. Put \n in the format string yourself.
  • Strings are char arrays with a null terminator, not objects. Use strcmp for equality (zero means equal), never ==.
  • The three legal main signatures are int main(void), int main(int argc, char **argv), and int main(int argc, char *argv[]). Lab 1 uses the first.

Lessons in this topic

Lesson What it covers
Introduction to C First C program, the four stages of gcc, the three legal main signatures, #include forms, C90 vs C99
Variables, printf & scanf Types, declarations, printf format specifiers, all four scanf patterns, strings as char arrays, strcmp, the Lab 1 CWE preview

Practice and deep dives

Practice this topic: C Basics or C Variables drills, or browse the practice gallery.

For the machine-level story of what &x resolves to and how the kernel loads a binary, see the machine model deep dive. For the five CWEs behind the Lab 1 reflection questions and their historic incidents, see the memory-safety deep dive. For why C strings are null-terminated (BCPL heritage, PDP-11 register pressure) and the C89 → C23 standards timeline, see the C history deep dive.

What comes next

Operators & Expressions — the arithmetic, comparison, logical, and bitwise operators, and the single most destructive typo in C (= vs ==).