递归方法字符串逆序输出问题

来源:互联网 发布:c语言break不好用 编辑:程序博客网 时间:2024/05/17 04:07

今天写个小程序,竟然出现我从来没见过的问题。输出含有乱码的字符串。不知何故?

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

void reverseDisplay(const char * string)
{
 char ch = *string;
 if(ch == '/n')
  return;
 else
 {
  reverseDisplay(string + 1);
  cout << ch;
 } 
}

int main()
{
 reverseDisplay("ABCD");

 cout <<endl;

 return 0;
}

 

结果输出,无法上传,下次传吧