-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathArrayAndFunction.cpp
More file actions
60 lines (49 loc) · 1.07 KB
/
ArrayAndFunction.cpp
File metadata and controls
60 lines (49 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// ArrayAndFunction.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
//Function Prototypes
int initialize(char theArray[80][20]);
void print_it(char theArray[80][20]);
int main(){
char firstName[80][20];
string lastName[80];
//Function Call
initialize(firstName);
//print the initialized array
print_it(firstName);
//input from user
cout << "Please enter 3 first names : ";
for (int i = 0; i < 3; i++){
cin >> firstName[i];
firstName[i][19] = '\0';
}
//print the names
print_it(firstName);
return 0;
}
//Function Definitions
int initialize(char theArray[80][20]){
/*Initializes all characters to NULL*/
for (int i = 0; i < 80; i++){
for (int j = 0; j < 20; j++){
theArray[i][j] = NULL;
}
}
return 0;
}
void print_it(char theArray[80][20]){
/*Prints the array in a grid format*/
for (int i = 0; i < 80; i++){
for (int j = 0; j < 20; j++){
if (theArray[i][0] != NULL){
cout << theArray[i][j];
}
}
if (theArray[i][0] != NULL){
cout << endl;
}
}
}