//string reversal using stack
//#include
//#include
#include
#include
#include
using namespace std;
void Reverse(char *C,int n)
{
stack S;
//loop for push
for (int i = 0; i
{
S.push(C[i]);
}
//loop for pop
for (int j = 0; j
{
C[j] = S.top();//overwrite the character at index i
S.pop();
}
}
int main()
{
char C[51];
printf ("Enter a string : ");
gets(C);
Reverse(C,strlen(C));
printf ("Output = %s",C);
printf ("\n");
}
这几个警告是怎么回事?大神们帮我解析一下啊。。。。。
还有就是代码是不是有问题,Reverse的两个for循环并列关系,应该是同步执行吧,如果是同步执行,那么第二个for循环就错了呀。。。。我感觉有点蒙