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

C++ examples for Data Type:char

Description

Output a character array to standard output by using ending character

Demo Code

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

void displayString(char stringArray[]);

int main(int nNumberofArgs, char* pszArgs[]){
    char charArray[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', '\0'};
    //from  w w  w  .  jav  a2 s.c  o  m
    displayString(charArray);
    cout << endl;

    return 0;
}

void displayString(char stringArray[]){
    for(int i = 0; stringArray[i] != '\0'; i++){
        cout << stringArray[i];
    }
}

Result


Related Tutorials