I want to reverse a char string in c++. I wrote this code:
#include <iostream>
#include <string.h>
using namespace std;
int main(){
char word[80] = "polymorphism";
char rev[80];
int i, j;
int l;
l = strlen(word);
for(i = 0, j = l; i < l-1; i++, j--){
word[j] = rev[i];
}
cout << rev << endl;
return 0;
}
In terminal it shows some characters like this:
83???uH??? ... Something like this
Aucun commentaire:
Enregistrer un commentaire