#include "syslib.h"
#include "string.h"main()
{
char *s = "Golden Global View";
char d[20],*p;

clrscr();

p = memccpy(d,s,'x',strlen(s));
if(p)
{
*p='\0';
printf("Char found: %s.\n",d);
}
else
{
printf("Char not found.\n");
}

getchar();
return 0;
}这段代码是我在书上抄的,执行有问题,请高手看看问题出在哪儿。谢谢,马上结贴

解决方案 »

  1.   

    #include <memory.h>
    #include <stdio.h>
    #include <string.h>
    main()
    {
    char *s = "Golden Global View";
    char d[20],*p;

    clrscr();

    p = (char *)memccpy( d, s,'x',strlen(s));
    if(p)
    {
    *p='\0';
    printf("Char found: %s.\n",d);
    }
    else
    {
    printf("Char not found.\n");
    }

    getchar();
    return 0;
    }
      

  2.   

    编译环境win32  console#include <process.h>
    #include <memory.h>
    #include "string.h"
    #include <stdio.h>char s[20] = "Golden Global View";int main()
    {
    char d[21];
    void *p;

    //system("cls");

    p = _memccpy(d, s, 'w', 20); if(p)
    {
    // *p='\0';
    printf("Char found: %s.\n",d);
    }
    else
    {
    printf("Char not found.\n");
    }

    getchar();
    return 0;
    }