Created
November 18, 2015 20:55
-
-
Save NickersF/a465f40154e3406659ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstring> | |
#include <string> | |
#include <iostream> | |
#include <iomanip> | |
using namespace std; | |
void printChar(char charArray[], char& ch); | |
void printStr(string strArray[], string& str); | |
int main() { | |
char char1 = 'A'; | |
char charArray[] = "ABCDEFG"; | |
string str1 = "A"; | |
string strArray = "ABCDEFG"; | |
strArray = strArray.c_str(); | |
// call the print char function | |
printChar(charArray, char1); | |
// call the print string function | |
printStr(strArray, str1); | |
return 0; | |
} | |
void printChar(char charArray[], char& ch) { | |
// print the single char | |
cout << "The single char stored in the variable char1 is: " << ch << endl; | |
// print the array of type char | |
cout << "The array of type char contains the following data: " << charArray << " "; | |
} | |
void printStr(string strArray[], string& str) { | |
int index; | |
// print the single string element | |
cout << "The single string character stored in the variable str1 is: " << str << endl; | |
// print the string array | |
for (index = 0; index < 50; index++) { | |
cout << strArray[index] << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment