a simple question regarding string copy in C# Programming - 葵花宝典
d*i
1 楼
Hi,
In a small code to implement string copy:
while(*a++ = *b++) ;
both a and b are char pointers. This code works but at the end, when *a
= *b = '\0' finishes, both a and b step one block beyond the last
character of the string which is "\0" because of the "++" operation.
Will this cause memory leak?
I have tested this code with GCC, it works but will this succinct
coding cause problem later?
Thank you.
In a small code to implement string copy:
while(*a++ = *b++) ;
both a and b are char pointers. This code works but at the end, when *a
= *b = '\0' finishes, both a and b step one block beyond the last
character of the string which is "\0" because of the "++" operation.
Will this cause memory leak?
I have tested this code with GCC, it works but will this succinct
coding cause problem later?
Thank you.