所以主线是 8 下面给出了代码,程序是关于反转字符串。基本上我已经给了字符值 80 我需要帮助所以如果我输入值它将反转字符串
#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;
}
}