C Programming, GCC, Make, and Git

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/77

flashcard set

Earn XP

Description and Tags

Flashcards covering key concepts about C programming, GCC, makefiles, and Git commands.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

78 Terms

1
New cards

What parameter must you provide to gcc to link in the math library?

-lm (e.g., gcc program.c -lm)

2
New cards

How can you find out the range of possible values for each numeric data type?

Check the limits.h header file (for integer types) and float.h (for floating-point types).

3
New cards

How can you get the value of Pi?

Use M_PI from math.h, or calculate it as acos(-1.0) or 4.0 * atan(1.0).

4
New cards

Does the math library have trigonometric functions?

Yes - sin, cos, tan, etc.

5
New cards

What function should you call before using the rand function?

srand() - to seed the random number generator.

6
New cards

What function checks if a character is alphabetic?

isalpha() from ctype.h.

7
New cards

What function converts a character to uppercase?

toupper() from ctype.h.

8
New cards

How can you convert a string that looks like an integer, to an integer?

atoi() or better: strtol().

9
New cards

How can you convert a string that looks like a real, to a double?

atof() or better: strtod().

10
New cards

What's wrong with the strcpy function?

No bounds checking, it can cause buffer overflows.

11
New cards

What function is better than the strcpy function?

strncpy() or better yet: strlcpy() or strcpy_s().

12
New cards

What function compares strings in alphabetic order, ignoring case?

strcasecmp() or stricmp() on Windows.

13
New cards

What is the strtok function used for?

Tokenizing/splitting strings.

14
New cards

What is the first parameter to strtok the second time you use it?

NULL - to continue tokenizing the same string.

15
New cards

What function searches a string for a character?

strchr() for first occurrence or strrchr() for last occurrence.

16
New cards

What function compiles a regular expression?

regcomp() from regex.h.

17
New cards

Name the three standard IO streams.

stdin, stdout, stderr.

18
New cards

What is the data type of the three standard IO streams?

FILE* (pointer to FILE).

19
New cards

What is the data type of all IO streams?

FILE*.

20
New cards

What's wrong with gets?

No bounds checking - vulnerable to buffer overflows.

21
New cards

What function should be used instead of gets?

fgets().

22
New cards

What is the function to open a file?

fopen().

23
New cards

What does fputs do?

Writes a string to a file stream.

24
New cards

What does fwrite do?

Writes binary data (a block of bytes) to a file.

25
New cards

What function detects a (genuine) end-of-file condition?

feof() - checks the end-of-file indicator.

26
New cards

What function provides random access in a file?

fseek().

27
New cards

What does fflush do?

Flushes the output buffer to the actual file/device.

28
New cards

If you are nervous, what system call should you use after fflush?

fsync() - forces physical write to disk.

29
New cards

What does sprintf do?

formats and writes to a string.

30
New cards

Why did mkstemp replace mktemp?

Security - mktemp had race conditions.

31
New cards

What function is used to get a piece of memory from the heap?

malloc().

32
New cards

What function is used to extend a piece of memory taken from the heap?

realloc().

33
New cards

What function is used to return a piece of memory to the heap?

free().

34
New cards

What is a "memory leak"?

Memory allocated but never freed.

35
New cards

What is a common use for the memset function?

Initializing/zeroing memory blocks.

36
New cards

What function provides an error message for the most recent error in a function call?

strerror(errno) or perror().

37
New cards

What functions provide "time travel" in C?

setjmp() and longjmp().

38
New cards

When does UNIX time start?

January 1, 1970, 00:00:00 UTC.

39
New cards

What function can be used to measure the CPU time used in a program?

clock().

40
New cards

What function installs an "exit handler" in a program?

atexit() - registers a function to be called at normal program termination.

41
New cards

What is the 1st step done by gcc?

Preprocessing.

42
New cards

What is the 2nd step done by gcc?

Compilation.

43
New cards

What is the 3rd step done by gcc?

Assembly.

44
New cards

What is the 4th step done by gcc?

Linking.

45
New cards

What flag stops gcc after the preprocessor?

-E.

46
New cards

What flag stops gcc after producing assembler code?

-S.

47
New cards

What flag stops gcc after producing relocatable binary code?

-c.

48
New cards

What does the -Wall flag do in gcc?

Enables most warning messages.

49
New cards

What does the -O flag do in gcc?

Enables optimization.

50
New cards

What does the -I flag do in gcc?

Adds a directory to the include search path.

51
New cards

What does the -l flag do in gcc? Lowercase L

Links with a library.

52
New cards

What does the -L flag do in gcc?

Adds a directory to the library search path.

53
New cards

What does the -D flag do in gcc?

Defines a preprocessor macro.

54
New cards

What does the preprocessor do with #include lines?

Replaces the line with the contents of the specified file.

55
New cards

What does the preprocessor do with #define lines?

Creates macro definitions.

56
New cards

What does the preprocessor do with #if lines?

Conditional compilation.

57
New cards

What files often contain the interface (declarations) in a C program?

Header files (.h).

58
New cards

What files often contain the implementation?

Source files (.c).

59
New cards

What is the make utility used for?

Automating the build process.

60
New cards

What is a target in a Makefile?

A file to be built or an action to be performed.

61
New cards

What is a dependency in a Makefile?

A file that must exist or be up-to-date before the target can be built.

62
New cards

What is an action in a Makefile?

An action is a shell command executed to build the target.

63
New cards

What character must precede an action?

A TAB character.

64
New cards

What does a clean target usually do in a Makefile?

Removes generated files.

65
New cards

How should non-file targets be identified in a Makefile?

Declared as .PHONY targets.

66
New cards

What are version numbers used for?

Tracking changes and releases over time.

67
New cards

How do revision control systems typically track previous versions of a file?

By storing deltas/diffs.

68
New cards

What is a Github Personal Access Token?

A token/password used for authentication with GitHub.

69
New cards

What does the command git init do?

Initializes a new Git repository.

70
New cards

What does the command git add do?

Stages files for the next commit.

71
New cards

What does the command git commit do?

Records staged changes to the repository.

72
New cards

What does the command git push do?

Uploads local commits to a remote repository.

73
New cards

What does the command git clone do?

Copies a remote repository to your local machine.

74
New cards

What does the command git status do?

Shows the status of working directory and staging area.

75
New cards

What does the command git checkout do?

Switches branches or restores files.

76
New cards

What does the command git tag do?

Creates, lists, or deletes tags.

77
New cards

What does the command git log do?

Shows commit history for the repository.

78
New cards

What is a Github pull request?

A request to merge changes from one branch into another.