std::cin >> *aa results in a bus error
- by Koning Baard XIV
I have this a class called PPString:
PPString.h
#ifndef __CPP_PPString
#define __CPP_PPString
#include "PPObject.h"
class PPString : public PPObject {
char *stringValue[];
public:
char *pointerToCharString();
void setCharString(char *charString[]);
void setCharString(const char charString[]);
};
#endif
PPString.cpp
#include "PPString.h"
char *PPString::pointerToCharString() {
return *stringValue;
}
void PPString::setCharString(char *charString[]) {
*stringValue = *charString;
}
void PPString::setCharString(const char charString[]) {
*stringValue = (char *)charString;
}
I'm trying to set the stringValue using std::cin:
main.cpp
PPString myString;
myString.setCharString("LOLZ");
std::cout << myString.pointerToCharString() << std::endl;
char *aa[1000];
std::cin >> *aa;
myString.setCharString(aa);
std::cout << myString.pointerToCharString() << std::endl;
The first one, which uses a const char works, but the second one, with a char doesn't, and I get this output:
copy and paste from STDOUT
LOLZ
im entering a string now...
Bus error
where the second line is what I entered, followed by pressing the return key.
Can anyone help me fixing this? Thanks...