Output a character array to standard output by using array length - C++ Data Type

C++ examples for Data Type:char

Description

Output a character array to standard output by using array length

Demo Code

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

void displayCharArray(char charArray[], int sizeOfArray);

int main(int nNumberofArgs, char* pszArgs[])
{
    char charArray[]={'a', 'b', 'c', 'd', 'e', 'f', 'g'};
    displayCharArray(charArray, 7);/* w  ww. ja v a2s . com*/
    cout << endl;

    return 0;
}

void displayCharArray(char charArray[], int sizeOfArray){
    for(int i = 0; i< sizeOfArray; i++){
        cout << charArray[i];
    }
}

Result


Related Tutorials