char inter1[10000];
char inter2[10000];
case IDC_RADIO4:


memset(inter1,0,sizeof(inter1));
memset(inter2,0,sizeof(inter2));

memcpy(inter1,english1,sizeof(english1));
memcpy(inter2,chinese56,(sizeof(chinese56)+1)); itoa(strlen(inter2),str,10);
MessageBox(dhWnd,str,"ok",MB_OKCANCEL);
return 1;
case IDC_RADIO5:
memset(inter1,0,sizeof(inter1));
memset(inter2,0,sizeof(inter2)); memcpy(inter1,english2,sizeof(english2));
memcpy(inter2,chinese78,sizeof(chinese78));

itoa(strlen(inter2),str,10);
MessageBox(dhWnd,str,"ok",MB_OKCANCEL);
return 1;

case IDC_ENGLISH:
WriteFile(hInt,inter1,(sizeof(inter1)-1),&dwBytesWritten,NULL);
CloseHandle(hInt);
if(hInt==hCom) OpenCom();
else           OpenLpt();
return 1;
case IDC_CHINESE:
for(i=0;i<4;i++)
WriteFile(hInt,inter2,(sizeof(inter2)-1),&dwBytesWritten,NULL);
CloseHandle(hInt);
if(hInt==hCom) OpenCom();
else           OpenLpt();
return 1;打出来的是“烫”。

解决方案 »

  1.   

    打出来的都是“烫”,说明字符串没有被赋值或者是都是0值
    另外MessageBox(dhWnd,str,"ok",MB_OKCANCEL);里面的str的赋值代码呢
      

  2.   

    english2,chinese78这些是什么变量啊? 有没有清零的??
      

  3.   

    /* MEMSET.C: This program uses memset to
     * set the first four bytes of buffer to "*".
     */#include <memory.h>
    #include <stdio.h>void main( void )
    {
       char buffer[] = "This is a test of the memset function";   printf( "Before: %s\n", buffer );
       memset( buffer, '*', 4 );
       printf( "After:  %s\n", buffer );
    }
    OutputBefore: This is a test of the memset function
    After:  **** is a test of the memset function
      

  4.   

    /* MEMCPY.C: Illustrate overlapping copy: memmove
     * handles it correctly; memcpy does not.
     */#include <memory.h>
    #include <string.h>
    #include <stdio.h>char string1[60] = "The quick brown dog jumps over the lazy fox";
    char string2[60] = "The quick brown fox jumps over the lazy dog";
    /*                           1         2         3         4         5
     *                  12345678901234567890123456789012345678901234567890
     */void main( void )
    {
       printf( "Function:\tmemcpy without overlap\n" );
       printf( "Source:\t\t%s\n", string1 + 40 );
       printf( "Destination:\t%s\n", string1 + 16 );
       memcpy( string1 + 16, string1 + 40, 3 );
       printf( "Result:\t\t%s\n", string1 );
       printf( "Length:\t\t%d characters\n\n", strlen( string1 ) );   /* Restore string1 to original contents */
       memcpy( string1 + 16, string2 + 40, 3 );   printf( "Function:\tmemmove with overlap\n" );
       printf( "Source:\t\t%s\n", string2 + 4 );
       printf( "Destination:\t%s\n", string2 + 10 );
       memmove( string2 + 10, string2 + 4, 40 );
       printf( "Result:\t\t%s\n", string2 );
       printf( "Length:\t\t%d characters\n\n", strlen( string2 ) );   printf( "Function:\tmemcpy with overlap\n" );
       printf( "Source:\t\t%s\n", string1 + 4 );
       printf( "Destination:\t%s\n", string1 + 10 );
       memcpy( string1 + 10, string1 + 4, 40 );
       printf( "Result:\t\t%s\n", string1 );
       printf( "Length:\t\t%d characters\n\n", strlen( string1 ) );
    }
    OutputFunction:   memcpy without overlap
    Source:      fox
    Destination:   dog jumps over the lazy fox
    Result:      The quick brown fox jumps over the lazy fox
    Length:      43 charactersFunction:   memmove with overlap
    Source:      quick brown fox jumps over the lazy dog
    Destination:   brown fox jumps over the lazy dog
    Result:      The quick quick brown fox jumps over the lazy dog
    Length:      49 charactersFunction:   memcpy with overlap
    Source:      quick brown dog jumps over the lazy fox
    Destination:   brown dog jumps over the lazy fox
    Result:      The quick quick brown dog jumps over the lazy fox
    Length:      49 characters
      

  5.   

    str没有问题,english2和chinese78直接打印也没有问题,就是传到inter1和inter2后,WriteFile出来后有问题,不明白!
      

  6.   

    你能保证是调用了memcpy以后才WriteFile的吗??
      

  7.   

    当然能,因为以下代码已经显示了inter1的长度。
    itoa(strlen(inter1),str,10);
    MessageBox(dhWnd,str,"ok",MB_OKCANCEL);
      

  8.   

    可能是变量未赋值。
    char inter1[10000];
    char inter2[10000];
    在分支
    case IDC_RADIO4:
    case IDC_RADIO5:
    中赋值,而在
    case IDC_ENGLISH:
    case IDC_CHINESE:
    分支中使用。
    这些分支之间无必然的调用顺序关系。