0
Pointer
hello guys may i ask a question? so today we have a lab that ask a user to enter a word and then by using a pointer it reverse the input from the user, the name of that function file is void reverse (chars[])? sorry iam.new at this c++😁
3 Respuestas
0
#include <iostream>
#include <cstring>
using namespace std;
void reverse(char a[])
{
for(int i=0,j=strlen(a)-1;i<j;i++,j--)
{
int temp = a[i]; //swapping
a[i] = a[j];
a[j] = temp;
}
for(int i=0;a[i]!='\0';i++)
cout<<a[i];
}
int main() {
char a[10];
cin>>a;
reverse(a); //function call
return 0;
}
//Since it's a single word I have not considered spaces
0
if you can😀, can you explain how this is going to work?
0
ooo i got it now..thanks alot you my savior😂😂😂