我想知道,怎样编辑代码,使完成这样的功能:
1。在目录C:\下建立一个名为output.txt的文件。
2。向文件中写入“载荷为  14000N”,其中14000l由变量Load来传递。
3。在对话框中点击button,就打开output.txt

解决方案 »

  1.   

    很简单
    点击按钮时:
    1.CStdioFile File.Open("c:\yourfile",cfile::modecrete)
    2.File.WriteString("your 载荷为  14000N");
    3.File.close
    4.CreateProcess("c:\\notepad.exe yourfile");
      

  2.   

    注意:
    14000室友变量Load来传递的。
    就是说,源码中不能出现14000这个数。
    这是我问问题的关键!!
      

  3.   

    你要的是这个?
    CString str;
    str.Format("载荷为  %dN", Load);
    ......
    File.WriteString(str);
    ......
      

  4.   

    我会了。
    是这样:
    float f=14000.0f;
    CStdioFile file("C:\\Windows\\temp\\output.txt",CFile::modeCreate|CFile::modeWrite);

    CString str;
    str.Format("Load is %.2f",f);
    file.WriteString(str);
    file.Close();

    WinExec("notepad.exe C:\\Windows\\temp\\output.txt",SW_SHOW); 可惜不能给自己分。
    这样,请大家给出更好的方法。
    看情况给分!!