Reputation: 1
So main line is 8
Code is given below and program is about reversing the string. Basically I have given the character value 80 I want help so If I enter value it will reverse the string
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
void reverse(char[], int);
int main()
{
char a[80];
int length;
cout << "\n Enter text:";
cin >> a;
length = strlen(a);
cout << "\n The orginal string is:";
puts(a);
reverse(a, length);
cout << "\n The modified string is:";
puts(a);
}
void reverse(char str[], int l)
{
char temp;
for (int i = 0; i < l / 2; i++) {
temp = str[i];
str[i] = str[l - i - 1];
str[l - i - 1] = temp;
}
}
Upvotes: 0
Views: 36