#include
using namespace std;
class Test
{
public
void input();
private
};
void Testinput()
{
char *temp;
cin >> temp;
cout << temp;
}
int main()
{
Test test;
test.input();
return 0;
}
이렇게 input 함수를 불러서 cin을 실행을 하면 seg falut가 나옵니다.
그런데
#include
using namespace std;
int main()
{
char* name;
cin >> name;
cout << name;
return 0;
}
이면 정상 출력이 되는군요...
하나는 객체를 생성해서 그 안에 잡힌 pointer에 문자열을 넣었고, 하나는 직접