Lecture 1 Flashcards
C programming basics
\n
newline
include <stdio.h></stdio.h>
int main (int argc, char** argv) {
printf(“Hello World!\n”);
return 0;
}
what does #include <stdio.h> mean?</stdio.h>
it adds the standard input/output functionality to program (header file)
include <stdio.h></stdio.h>
int main (int argc, char** argv) {
printf(“Hello World!\n”);
return 0;
}
what is int argc?
integer argument for main( )
include <stdio.h></stdio.h>
int main (int argc, char** argv) {
printf(“Hello World!\n”);
return 0;
}
what is char** argv?
char pointer (string array) argument for main( )
include <stdio.h></stdio.h>
int main (int argc, char** argv) {
printf(“Hello World!\n”);
return 0;
}
what does \n mean?
new line
include <stdio.h></stdio.h>
int main (int argc, char** argv) {
printf(“Hello World!\n”);
return 0;
}
what does return 0 mean?
returns 0 when main is done executing, 0 here means the program ran and executed normally
what does GCC stand for?
GNU Compiler Collection
What is gcc?
software program/compiler
ex) you use gcc file.c -o file to compile program in terminal
gcc first.c -o first
what does -o first make?
executable object file named “first”
printf(“%s\n”, “Hello World”);
what does the input/output do here with the format specifier and string?
it puts “Hello World” into %s to satisfy the string format specifier, goes to standard out then prints “Hello World”
how to declare a variable?
data type variable name;
how to declare a variable with initialization?
data type variable name = value;
should you initialize or not initialize when declaring a variable?
initialize, the value assigned if you don’t initialize will not be 0 every time –> it will be assigned to whatever is left in memory
what are the name restrictions for variables?
reserved words (for, malloc, etc), cannot exceed 31 characters
cannot start with a digit
what is allowed for the names of variables?
can contain letters, digits, and underscores
ex) _brent