Week 5 (Interactivity) Flashcards Preview

C++ > Week 5 (Interactivity) > Flashcards

Flashcards in Week 5 (Interactivity) Deck (21):
1

what is the preferred way to input a string?

getline(cin, inputLine);

2

what is the syntax for the get line function

getline(, )

3

how to get a char input and store it?

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

4

how to ignore characters in the buffer?

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

5

how to get the length of a string?

integerIdentifier = stringIdentifier.length( )

6

How to concatenate strings?

+

7

What are c-strings?

Arrays of chars that act as strings.

8

how do you copy strings with string objects?

strcpy(name2, name)

9

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

cin >> setw(n) >> word;

10

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

cin.getline(arrayVariable, size)

11

What to include math library functions

#include

12

what to include for random numbers

#include

13

what function to call to return a integer random number.

rand()

14

what does a seed value do?

Helps generate random numbers

15

How to set a seed value?

srand();

16

how to make the seed value more random

seed = time(0);

17

Five steps for file input:

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

18

what is the header file for file input?

#include

19

what are the types of objects for file input / output

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

20

how do you open a file for input/output?

outfile/infile.open("fileName.txt");

21

how to close file

outputFile.close();