locked
我在vc里写wp遇到个问题 RRS feed

  • 问题

  • 我像读取txt文件放入textblock2控件里

    FILE* f;
     errno_t err;
     err = fopen_s(&f, "crt_fopen_s.c", "r");
     wchar_t str;
     fread(str, 100, 1, f);
     Platform::String^ pstr = ref new String(str);
     textBlock2->Text = pstr;
     fclose(f);

    调试不出来了 变量类型总出错 请问应该怎样改

    2014年7月21日 11:54

答案

  • Solved. Set the content of 1.txt "true"

           wchar_t* str = new wchar_t[100];
    FILE *fp;

    errno_t err;
    err = _wfopen_s(&fp, L"1.txt", L"r");

    fgetws(str,90, fp);
    Platform::String^ pstr = ref new Platform::String(str);
    textBlock2->Text = pstr;

    2014年7月22日 12:40

全部回复

  • 你好,

    对C++不熟悉,找了几个VC++读取TXT的示例,希望有帮助,

    http://msdn.microsoft.com/en-us/library/y52yxde8.aspx

    http://support.microsoft.com/kb/307384

    谢谢!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年7月22日 5:29
    版主
  • Solved. Set the content of 1.txt "true"

           wchar_t* str = new wchar_t[100];
    FILE *fp;

    errno_t err;
    err = _wfopen_s(&fp, L"1.txt", L"r");

    fgetws(str,90, fp);
    Platform::String^ pstr = ref new Platform::String(str);
    textBlock2->Text = pstr;

    2014年7月22日 12:40