【发布时间】:2013-03-29 22:29:20
【问题描述】:
我们的老师希望我们编写一个反转字符数组顺序的程序。所以就像如果用户输入“hello”,程序会输出“olleh”。
这是我们得到的功能:
void reverse_string(char coolstring[11], char newcoolstring[11])
{
int count = 0, count2 = 0;
while(coolstring[count] != '\0')
{
count++;
}
count -= 1;
cout << coolstring[count];
system("pause");
while(coolstring[count] != 0)
{
newcoolstring[count] = coolstring[count2];
count -= 1;
count2 += 1;
}
}
但它不起作用,我在尝试使其起作用时无法找出原因。你能给我指出正确的方向吗?
任何帮助将不胜感激
【问题讨论】:
-
“它不起作用”不是对问题的有用描述。
-
那是你老师给你的代码,你的代码在哪里?你试过什么?
-
她故意给你非工作代码。你不应该弄清楚如何解决它吗?