[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help using getline(char_type*, streamsize)
From: |
David Lazanja |
Subject: |
Re: Help using getline(char_type*, streamsize) |
Date: |
Wed, 5 Oct 2005 12:37:47 -0400 |
User-agent: |
KMail/1.8 |
On Wednesday 05 October 2005 12:27, jalkadir wrote:
> I am trying to get character string from the user, to do that I use
> getline(char_type*, streamsize), but I get a segmentation fault??!!
>
> Can anyone give me a hand, what am I doing wrong?
>
> --snip
> char* cstr;
>
> std::cout << "House/Appartment # ";
> std::cin.getline(cstr, CHAR_MAX); //<<==seg fault
Your pointer is not pointing to memory. I would do it like this:
char cstr[CHAR_MAX];
std::cin.getline(cstr, CHAR_MAX);
-David
--
# Department of Applied Physics and Applied Mathematics
# Columbia University