SO my professor gave my a header file with declared functions that are not defined. Here are the 2 that i am working with:
/*
Builds a Two Dimensional array of the given size
-- cols: The number of columns in the matrix
-- rows: The number of rows in the matrix
-- **matrix: A pointer to a matrix to be built, which is not initialized yet, but merely declared before being a parameter here.
-- returns a ponter to a pointer to a char, which is the pointer to the matrix
*/
char ** build_matrix(int rows, int cols)
{
}
/*
Fills a matrix from std in (command line terminal input)
-- cols: The number of columns in the matrix
-- rows: The number of rows in the matrix
-- **matrix: The matrix to be filled
-- Should simply accept input via cin or getline, etc.
*/
void fill_matrix(int rows, int cols, char **matrix)
{
}
I am also supposed to compile with: g++ *.cpp -o test And then run my program using: test < sample_input.txt
test < sample_input.txt: this is supposed to use sample_input.txt and cin. So when you use cin it will go to the txt file and use that as input.
Here is the txt file:
5 5
r g p g p
k p o f z
q d x s t
v y r y j
e w y t e
dog
7 7
u c d z q c y
k i m i f z e
k r u c s i p
h o a w b y w
n m o b h o y
s q j e r i x
w u n t g a x
bark
11 11
b r o r t u h q v v q
k k w e o y l a m h d
w k f h q y t y j b q
r h k t m s q l s k q
g t z a y g i w t v z
z n o e v m y m p w b
r v a w n c l q j r o
b x o k f v w o s o i
r j y k z x c t n x s
q g y d v p g g r k c
k m p a i y u w r e o
theweatherisnice
4 8
1 0 1 0 1 1 1 0
0 0 1 1 1 1 0 1
1 0 0 1 0 1 1 0
1 1 0 1 0 1 1 1
111100
In main I cin >> row and col and that will use the first 2 numbers as row and col. Then I will pass that into my function to build my array.
My question is, how do I build the array? and how to fill?