一个转换字符串的问题,总是不能运行,大家帮我看看,谢了先!
字符串的反向输出。要求不能用库函数,不能使用数组来暂存指针指向的内容。
编好后总是运行不过去,各位高手们多多指教,小弟先谢了!
#include <stdio.h>
#include <stdlib.h>
void reverse_string(char * strings)
{
char *head = strings;
char *tail = strings;
char tmp;
while(*tail != '\0')
{
tail++;
}
tail--; //points to the tail of this string
while(tail > head)
{
tmp = *head;
head++ = *tail; ---》这个地方不能运行,???
*tail-- = tmp;
}
printf("%s", *strings);
}
void main()
{
char *str = "Hello, World";
reverse_string(str);
}