i tried to swap 2 char arrays by using a temporary char array temp. but it gave me wrong output on hackerblocks.
i tried to swap them using pointers and it worked. why??
what can be the reason?
What is the difference between swapping strings by copying and swapping strings by using pointers?
This is because when you are using the temporary char, then it means you are passing parameters by call by value, thus any changes you made will not be reflected on the main code, because you are working on copies and not the exact values, but when you are using pointers, it means you are passing by references and thus any changes you make will be reflected easily because you are working on actual copies
No, not at all. I have not made any function that I would deal with call by values and call by reference.
Please try to understand the question.
Can you send the code then ??? I will just check it
i was solving a problem on hackerrank. when i copies strings using a temporary char array, it failed in 3 test cases. but when i swapped them using a car type pointer, it passed all the test cases.
should i send the hackerrank link???