Midterm #2 Flashcards
(52 cards)
types of input
arguments, cin»_space;, and getline
types of output
cout«
argc
argument counts
argv
argument variables
how to compile a program
g++ -o example.out example.cpp
how to run a program
./example.out (inline arguments)
(./example.out 3 10 abc) agrc
4
(./example.out 3 10 abc) argv
argv[0], argv[1], agrv[2], argv[3]
(./example.out A B C 1 2)
argc?
6
(./example.out A B C 1 2) argv[3]
c
(./example.out A B C 1 2) argv[5]
2
(./example.out A B C 1 2) argv[4] + argv[5]
we cannot have sum of two strings “1” + “2” is an invalid type of addition operator
atoi (str)
convert str to an int value
atof (str)
convert str to a double value
cout«
displays a prompt to whoever is running the program
std::
formal syntax (don’t need if “using namespace std”)
cin»
whatever the user puts into the program (becomes a variable)
getline()
if the variable you want contains a space
getline() (written out)
getline (cin, variable with space)
\
the back-slash
"
double quote marks
\t
a horizontal tab
\n
new line
std::endl
new line