char 配列の 2 つの値を並べ替えて読み込もうとしています。コンパイル時にエラー/警告はありません。しかし、プログラムは起動時にクラッシュしますか?
#define s_size 9
struct _struct {
public:
void SetItemName(int i, char *c) {
strcpy(item[i], c);
}
const char *GetItemName(int i) const {
return item[i];
}
private:
char* item[s_size];
};
_struct mystruct;
void Getvalue()
{
printf(mystruct.GetItemName(0));
}
void Setvalue( )
{
mystruct.SetItemName(0,"hello");
mystruct.SetItemName(1,"world");
Getvalue();
}