The Partridge Family were neither partridges nor a family. Discuss.
-
Clodi
- Posts: 175
- Joined: November 18th, 2012, 7:47 pm
Post
by Clodi » January 25th, 2013, 3:15 pm
hello guys,
how you doin?
Code: Select all
void putString( const char* pStart, const char*pEnd )
{
for ( ; pStart < pEnd; pStart ++ )
{
putchar( *pStart );
}
}
any idea why this function actually works fine???
According to me it shouldn't work as I declare char* pStart as constant and then I change it permanently throughout the function..
Last edited by
Clodi on January 26th, 2013, 6:59 pm, edited 2 times in total.
-
Musi
- Posts: 106
- Joined: November 25th, 2012, 1:06 am
Post
by Musi » January 25th, 2013, 4:14 pm
Ah that's because "const char* pStart" makes it so you cant change the value that the pointer points to. If you want to make it so the actual pointer can't change what it points to then you should put const after the asterisk.
Code: Select all
const char* pStart // The object that the pointer points to cannot be changed.
char* const pStart // The pointer cannot change what it points to.
const char* const pStart // Both the object and the pointer cannot be changed.
Last edited by
Musi on January 25th, 2013, 4:27 pm, edited 1 time in total.
Musi
There are 10 types of people that understand binary.
Those that do, and those that don't.
-
Clodi
- Posts: 175
- Joined: November 18th, 2012, 7:47 pm
Post
by Clodi » January 25th, 2013, 4:23 pm
ohhh. thank you so much. I didn't know that.
So, in case I wanted to lock a pointer completely?
?
-
Musi
- Posts: 106
- Joined: November 25th, 2012, 1:06 am
Post
by Musi » January 25th, 2013, 4:28 pm
Yep exactly. ( edited my last post )
Musi
There are 10 types of people that understand binary.
Those that do, and those that don't.
-
Clodi
- Posts: 175
- Joined: November 18th, 2012, 7:47 pm
Post
by Clodi » January 25th, 2013, 4:58 pm
A big thank you.