Week 5 (Interactivity) Flashcards

1
Q

what is the preferred way to input a string?

A

getline(cin, inputLine);

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

what is the syntax for the get line function

A

getline(, )

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

how to get a char input and store it?

A

cin.get(ch); ch = cin.get

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

how to ignore characters in the buffer?

A

cin.ignore(n,c);
(n= numbers of characters to skip)
(c = character)
skips n characters or until c is encountered

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

how to get the length of a string?

A

integerIdentifier = stringIdentifier.length( )

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

How to concatenate strings?

A

+

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

What are c-strings?

A

Arrays of chars that act as strings.

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

how do you copy strings with string objects?

A

strcpy(name2, name)

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

how can you limit the amount of characters stored into a c-string

A

cin&raquo_space; setw(n)&raquo_space; word;

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

How do you read in a whole line with c string?

A

cin.getline(arrayVariable, size)

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

What to include math library functions

A

include

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

what to include for random numbers

A

include

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

what function to call to return a integer random number.

A

rand()

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

what does a seed value do?

A

Helps generate random numbers

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

How to set a seed value?

A

srand();

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

how to make the seed value more random

A

seed = time(0);

17
Q

Five steps for file input:

A
Include header file
define file stream object
Open file
Use File (read/ write)
Close file
18
Q

what is the header file for file input?

A

include

19
Q

what are the types of objects for file input / output

A

ofstream - output file
ifstream - input file
fstream - file stream, input and output

20
Q

how do you open a file for input/output?

A

outfile/infile.open(“fileName.txt”);

21
Q

how to close file

A

outputFile.close();