C++ char array as String Output a character array to standard output

Description

C++ char array as String Output a character array to standard output

#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'};
    // w ww .j  av a2s .  c  o  m
    displayString(charArray);
    cout << endl;

    return 0;
}

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



PreviousNext

Related