lundi 16 mars 2015

What is the issue with this reverse array code in c++?


The program compile fine, but crashes when is running and shows this : Process terminated with status -1073741819



void reverse(char *str){

char * end1 = str;
char tmp = 'c';
if(str){
while(*end1){
++end1;
}
--end1;

while(str<end1){
tmp=*str;
*str=*end1;
*end1=tmp;
str++;
end1--;
}
}
}


Any idea ?




Aucun commentaire:

Enregistrer un commentaire