samedi 20 avril 2019

Problem printing CHAR array in C ++ language

I try to print an array and I can not. Does anyone have any idea why ?

In the Main.cpp file there is of course a function call.

My code:

Game.cpp:

#include "Game.h"

Game::Game() {
    char example[] = "PASS";
}

bool Game::PrintArray() {
    cout << example[0] << endl;
    return true;
}

Game.h:

#include <iostream>
#include <array>
#include <iostream>
#include <string>

using namespace std;

#ifndef GAME_H_
#define GAME_H_

class Game {
private:
    char example[];
public:
    Game();
    bool PrintArray();

};

#endif /* GAME_H_ */

Aucun commentaire:

Enregistrer un commentaire