编译没错误,运行崩溃了
#include <stdio.h>
void delspace(char *);
int main(void)
{
char *ptr = " asd as,vs aw";
delspace(ptr);
puts(ptr);
}
void delspace(char *ps)
{
char *pt = ps;
while (*ps != '\0')
{
if (*ps != ' ')
{
*pt = *ps;
pt++;
}
ps++;
}
*pt = '\0';
}