小编bla*_*edj的帖子

分段错误错误

`我正在尝试编写一个反转两个字符串的程序,虽然我做得很好但是当我运行它时,程序运行到第26行,然后我得到分段错误错误.该程序编译良好.我想知道我的功能是否有一个简单或明显的问题,我没有看到,任何帮助将不胜感激!

提前致谢

#include <iostream>
#include <string>
using namespace std;

// Reversing the characters in strings.

void reverse(string str);
void swap(char * first, char *last);

int main() {
    // declarations and initialization
    string str1;
    string str2;

    cout << "Please enter the first string of characters:\n";
    cin >> str1;

    cout << "Please enter the second string of characters:\n";
    cin >> str2;

    cout << "The strings before reversing are:" << endl;
    cout << str1 << " " << str2 << endl;

    // reverse …
Run Code Online (Sandbox Code Playgroud)

c++ segmentation-fault

4
推荐指数
1
解决办法
691
查看次数

标签 统计

c++ ×1

segmentation-fault ×1