The following code:
void reverse(char* string)
{
char* first = string;
char* last = string + strlen(string);
while (first < last)
{
--last;
char temp = *first;
*first = *last;
*last = temp;
++first;
}
}
breaks at the line: *first = *last in MSVC 2015. Can you explain why? What would be the correct way of performing the assignment?
Aucun commentaire:
Enregistrer un commentaire