Week 5 (Interactivity) Flashcards Preview

C++ > Week 5 (Interactivity) > Flashcards

Flashcards in Week 5 (Interactivity) Deck (21)
Loading flashcards...
1
Q

what is the preferred way to input a string?

A

getline(cin, inputLine);

2
Q

what is the syntax for the get line function

A

getline(, )

3
Q

how to get a char input and store it?

A

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

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

5
Q

how to get the length of a string?

A

integerIdentifier = stringIdentifier.length( )

6
Q

How to concatenate strings?

A

+

7
Q

What are c-strings?

A

Arrays of chars that act as strings.

8
Q

how do you copy strings with string objects?

A

strcpy(name2, name)

9
Q

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

A

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

10
Q

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

A

cin.getline(arrayVariable, size)

11
Q

What to include math library functions

A

include

12
Q

what to include for random numbers

A

include

13
Q

what function to call to return a integer random number.

A

rand()

14
Q

what does a seed value do?

A

Helps generate random numbers

15
Q

How to set a seed value?

A

srand();

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();