int send(constchar * ftp, constchar * user, constchar * pass, constchar * pathondisk, char * nameonftp)
{
char * buf=nameonftp;
cout<<pathondisk<<endl;//Here i get the correct output
strcat(buf,".txt");
cout<<pathondisk<<endl;//but here i get only one single character
}
I have only pasted code that was causing problem, would you please tell me how this can happen? is there anything wrong the way i am using strcat(). Its weird because the 'pathondisk' is a const char and even though i applied strcat() on another string the contents of 'pathondisk' are altered.
Thanks
Regards
I intended to add ".txt" to nameonftp that was stored to "buf", everything fine there but how come the contents of pathondisk changed?
thats what i am asking..
thanks for replying
Well you aren't actually. You are making buf point to the same thing nameonftp points to, so when you modify buf, you are also modifying nameonftp.
If nameonftp isn't big enough to hold the extra characters, it will keep writing off into other address space, which might include some of pathondisk's characters, which is why it was modified.