代码如下:
在执行下面的代码前,我之前的操作是从内存中获取到了pcBrightInfo的值,
其内容为"d\TLD <4,$..",而且为该变量申请了足够的内存。输出到文本文件中时,也就是下面红色部分: 如果直接按照下面所示执行,输出为:100 92 ?4 ?6 ?8 ?0 ?2 ?4 ?6 ?8 ?;
?不知何处而来;如果把注释部分去掉,可以消除?号,但此时数字不能在一行显示了。÷
而且去掉一行注释也是有?存在。所以请高手分析下,是不是往文件写的时候覆盖了?是哪里的问题?应该如何解决呢???
                CString cstr;

cstr = (LPCSTR)pcBrightInfo; for(int i=0;i <cstr.GetLength()+1;++i) 


char t=cstr.GetAt(i); 
int a = (int)t;

_itoa_s(a,pch,4,10);
ReportFile.Write(pch,4);
//ReportFile.Write("\r\n",4);
//ReportFile.Write("\r\n",4);

解决方案 »

  1.   

    CHAR szPch[4];
    ZeroMemory(szPch, 4);
    swprintf(szPch, "%d", a);
    ReportFile.Write(pch,4); 
      

  2.   

    CHAR szPch[4];
    ZeroMemory(szPch, 4);
    swprintf(szPch, "%d", a);
    ReportFile.Write(szPch,4); 
      

  3.   

    pcBrightInfo是什么数据?如果不是纯文本,不要用CString
      

  4.   

    你的话很绕,双重否定啊。。我从内存中取出pcBrightInfo的内容就是“”中的那些东西啊
      

  5.   

    用你的代码,出问题了:
    error C2665: 'swprintf' : none of the 2 overloads could convert all the argument types
    1>        d:\program files\microsoft visual studio 8\vc\include\swprintf.inl(36): could be 'int swprintf(wchar_t *,size_t,const wchar_t *,...)'
    1>        d:\program files\microsoft visual studio 8\vc\include\swprintf.inl(85): or 'int swprintf(wchar_t *,const wchar_t *,...)'
    1>        while trying to match the argument list '(char *, int, const char [3], int)'
      

  6.   

    工程设置属性设置不使用UNICODE