Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- // char array[] = {'j','o', 'w', 'i','e'};
- char array[] = "jowie";
- cout << array << endl; // will print the full array
- for (size_t i = 0; i < sizeof(array); i++) {
- cout << array[i] << endl; // So will this
- }
- cout << endl << endl;
- for (size_t i = 0; i < sizeof(array); i++) {
- cout << "Entry " << i << " contains: " << (int)array[i] << endl; // you are only able to make the extra entry visible if u cast it.
- /*
- you'll see that there is one entry added. This one is invisible, its called the NULL operator.
- this way the C++ can know where your array actually stops.
- */
- }
- cout << endl << endl;
- char array_2[] = "florian";
- int k = 0;
- while (true) {
- /*if (array_2[k] == 0) {
- break;
- }*/
- if (array_2[k] == NULL) { // NULL is in fact 0, hence why this works too. (The extra character is infact NULL(0)
- break;
- }
- cout << array_2[k] << flush;
- k++;
- }
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement