Header Files, Makefiles, Processes, and Signals Flashcards

(40 cards)

1
Q

What should you do to prevent errors when using #define?

A

Use #define wisely.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is important to remember about structuring code?

A

Structure code into multiple files (.c and .h).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the benefit of using Makefiles?

A

Automate compilation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fill in the blank: A library is a collection of _______.

A

Precompiled functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the role of *.h (Header files) in C programming?

A

Declarations & interfaces.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What do *.c (Source files) contain?

A

Code definitions, logic.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What elements are included in headers?

A
  • # include <stdio.h></stdio.h>
  • # define macros (e.g. M_PI)
  • struct definitions
  • typedefs
  • Function prototypes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What elements are excluded from headers?

A
  • Function bodies (definitions)
  • Executable code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the file stack.h contain?

A

Structure & function prototypes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the purpose of include guards in C headers?

A

Prevent duplicate definitions in headers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the syntax for include guards?

A

ifndef __STACK_H

#define __STACK_H
// … header content …
#endif

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an alternative to include guards?

A

pragma once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the command to compile a C source file into an object file?

A

gcc -c stack.c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the command to link object files into an executable?

A

gcc myProgram.o stack.o -o myProgram

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the two types of libraries in C?

A
  • Static (.a)
  • Dynamic (.so)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the linker flag to use the math library in C?

A

-lm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the purpose of Makefiles?

A

Automate compilation.

18
Q

What command is used to run the Makefile?

A

make myProgram

19
Q

What happens when a dependency like stack.h is updated?

A

Recompile if any dependency is updated.

20
Q

Fill in the blank: Header files contain ______, not definitions.

A

Declarations.

21
Q

What does the command gcc -c file.c do?

A

Creates object files.

22
Q

What is a key point about libraries in C?

A

Use -l<name> for others.</name>

23
Q

What is one advantage of using Makefiles?

A

Keep project organized.

24
Q

What is a Process?

A

A running instance of a program with a unique PID and one parent process, except for PID 0.

25
What does everything in UNIX represent?
Everything in UNIX is either a file or a process.
26
What is the purpose of POSIX?
Makes code portable across UNIX-like systems.
27
What did The Open Group create?
The Single UNIX Specification.
28
Which Linux distributions are mostly POSIX compliant?
* Ubuntu * RedHat
29
What command shows running processes?
ps
30
What is the purpose of the top command?
Provides a live view of CPU/memory/processes.
31
What symbol is used to run a process in the background?
&
32
What does the jobs command do?
Shows your background jobs.
33
What command is used to terminate a process?
kill
34
What is the function of nohup?
Keeps a job running even after logout.
35
What do nice and renice commands do?
Set process priority.
36
What happens in the foreground mode?
Shell waits for the process to finish.
37
What happens in the background mode?
Shell continues running.
38
What command is used to pause a foreground job?
CTRL+Z
39
How do you kill a process by job number?
kill %1
40
How do you kill a process by PID?
kill 12345