Re: pointer concepts
- From: "Vladimir S. Oka" <novine@xxxxxxxxxxxxxxx>
- Date: Fri, 10 Feb 2006 06:33:01 +0000 (UTC)
geshule@xxxxxxxxxxx wrote:
elu wrote:
You can run into the problem again if you read more
characters than you allocated.
I agree with you on that.
But the codes below works even if you input more than 10 characters?
Why?
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
char *str;
str = new char[10];
printf("Enter a string to reverse\n");
scanf("%s",str);
cout << strlen(str)<< endl;
system("pause");
return 0;
}
I don't know, it's not C!
Please post C++ questions to comp.lang.c++
<OT>
I don't see why would it work for more characters than you allocate.
</OT>
--
BR, Vladimir
Goto, n.:
A programming tool that exists to allow structured programmers
to complain about unstructured programmers.
-- Ray Simard
.
- References:
- pointer concepts
- From: Newbie
- Re: pointer concepts
- From: Nelu
- Re: pointer concepts
- From: geshule
- pointer concepts
- Prev by Date: Re: Pointer to array of structs?
- Next by Date: Re: Comparisons
- Previous by thread: Re: pointer concepts
- Next by thread: Re: pointer concepts
- Index(es):
Relevant Pages
|