0

Plz give me the code to reverse a string of integers and store the reversed string in another array.thanks un advance.

29th Dec 2016, 8:21 AM
Raaman Kilaru
Raaman Kilaru - avatar
2 Respostas
0
#include<iostream> #include<cstdlib> #include<iomanip> using namespace std; int main() { char a[100],b[100]; int len=0; char temp; cout<<"Enter the integer string"<<endl; getline(cin,a); //retrieving input integer while(a[len] != '\0') len++; // gets total length of string for(int i=0;i=len/2;i++) // reversing string { temp=a[i]; a[i]= a[len-i]; a[len-i]=temp; } for(int i=0;i=len;i++) // copying string { b[i]=a[i]; } return 0; }
29th Dec 2016, 12:37 PM
Manikanta Nallamalli (Mittu)
Manikanta Nallamalli (Mittu) - avatar
0
i tried this code .actually the string what I'm saying is of integers and this code is not working for that,even after declaring a and b arrays as int. thanks
29th Dec 2016, 1:34 PM
Raaman Kilaru
Raaman Kilaru - avatar