Return to Snippet

Revision: 41633
at February 21, 2011 22:27 by marwac6


Updated Code
#include <iostream> #include <cstring> // for the strlen() function int main() {
using namespace std; const int Size = 15; char name1[Size];
// empty array
char name2[Size] = �C++owboy�; // initialized array // NOTE: some implementations may require the static keyword // to initialize the array name2
cout << �Howdy! I�m � << name2; cout << �! What�s your name?\n�; cin >> name1;
cout << �Well, � << name1 << �, your name has �; cout << strlen(name1) << � letters and is stored\n�; cout << �in an array of � << sizeof(name1) << � bytes.\n�; cout << �Your initial is � << name1[0] << �.\n�; name2[3] = �\0�;
// null character
cout << �Here are the first 3 characters of my name: �; cout << name2 << endl; return 0;
}

Revision: 41632
at February 21, 2011 22:17 by marwac6


Initial Code
#include <iostream> #include <cstring> // for the strlen() function int main() {
using namespace std; const int Size = 15; char name1[Size];
// empty array
char name2[Size] = �C++owboy�; // initialized array // NOTE: some implementations may require the static keyword // to initialize the array name2
cout << �Howdy! I�m � << name2; cout << �! What�s your name?\n�; cin >> name1;
cout << �Well, � << name1 << �, your name has �; cout << strlen(name1) << � letters and is stored\n�; cout << �in an array of � << sizeof(name1) << � bytes.\n�; cout << �Your initial is � << name1[0] << �.\n�; name2[3] = �\0�;
// null character
cout << �Here are the first 3 characters of my name: �; cout << name2 << endl; return 0;
}

Initial URL


Initial Description


Initial Title
Strings and arrays

Initial Tags
array

Initial Language
C++