#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NUL '\0'
int iswhite(int ch);
void deblank(char *string)
{
char *src;
char *dest;
int ch;
src = string;
dest = string++;
while ((ch = *src++) != NUL)
{
if (iswhite(ch))
{
if (src == string || !iswhite(dest[-1]))
{
*dest++ = ' ';
}
}
else
{
*dest++ = ch;
}
}
*dest = NUL;
}
int iswhite(int ch)
{
return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\v' || ch == '\f' || ch == '\r';
}
int main()
{
char *string = "hello world! hello world!!!";
deblank(string);
printf("%s\n", string);
system("pause");
return 0;
}
在vc6.0下为什么会出现如下的错误,如何改?
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\kernel32.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\KernelBase.dll', no matching symbolic information found.
First-chance exception in Chapter4_14.exe: 0xC0000005: Access Violation.
同样的代码用gcc编译会产生如下的提示:
Program received signal SIGINT, Interrupt.
In NlsUpdateSystemLocale () (C:\Windows\syswow64\kernel32.dll)
Debugger finished with status 0