ISN'T THIS CALL BY VALUE......if it is,then i should get output as HARMONIOUS becoz any changes made on the formal parameters does not get reflected in the actual parameters in CALL BY VALUE.
but am getting sumthing else . why ?
You are passing a pointer, by value. Yes, I know, it looks like it should be some kind of char array being passed by value. It isn't.
So the function JumbleUp receives a copy of a pointer, pointing at the memory location containing "HARMONIOUS". So it works on that memory space.
There is no copy of "HARMONIOUS" made; only a copy of a pointer to it, and it doesn't matter that the pointer is a copy - it still points to the exact same memory.
If you were passing a proper C++ string, then that string would be copied. As an aside, why are you coding so heavily in C? Why not C++?
Thanks for explaining but am still unclear. how do i know that a pointer is being passed ? and why is the char array not being passed ? am a beginner , so plz explain elaborately.
You say it's C++, but there's almost no C++ in it. It uses C style strings and an ugly typedef; you're clearly thinking in C.
Anyway, this is how the C and C++ language works. When you pass an array, what actually gets passed is a pointer to the start of the array.
how do i know that a pointer is being passed ?
You know this because when you were learning about C and C++, you read it somewhere or maybe someone told you.
I don't know how to say it more elaborately that this. It's how C and C++ work. When you pass an array, what actually gets passed is a a pointer to the start of the array.