会管道的ggjj进来看看吧,litte girl有问题

nana2zs 2007-05-06 09:42:42
我想将文本文件中的数据输入到程序中,怎么实现,给个代码看看好不
跪求
...全文
252 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
stcatz 2007-05-06
  • 打赏
  • 举报
回复
// print the content of a text file
#include <iostream>;
#include <fstream>;
using namespace std;

int main () {

ifstream infile;

infile.open ("test.txt" , ifstream::in);

while(infile.good())
cout << (char)infile.get();

infile.close();

return 0;
}
stcatz 2007-05-06
  • 打赏
  • 举报
回复
跪求是要上下跪照片的 - -#
dai_weitao 2007-05-06
  • 打赏
  • 举报
回复
BOOL CreateProcess(
LPCTSTR lpApplicationName, // name of executable module
LPTSTR lpCommandLine, // command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
BOOL bInheritHandles, // handle inheritance option
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // new environment block
LPCTSTR lpCurrentDirectory, // current directory name
LPSTARTUPINFO lpStartupInfo, // startup information
LPPROCESS_INFORMATION lpProcessInformation // process information
);
第一个参数是MODULE, 第二个参数才是命令行, 你前面差个NULL参数.
stcatz 2007-05-06
  • 打赏
  • 举报
回复
你确定文件路径不是这样写
D:\my program\test\判断三角形\Debug\判断三角形.exe

另外你的问题可能去VC版问合适一些。
nana2zs 2007-05-06
  • 打赏
  • 举报
回复
这位大哥误会了我用的是CreatePipe和CreateProcess,有人交了我一段代码
if(!CreateProcess("D:\\my program\\test\\判断三角形\\Debug\\判断三角形.exe < D:\\my program\\case.txt","/c dir/?",NULL,NULL,TRUE,NULL,NULL,NULL,&si,&pi))
{
MessageBox("Error on CreateProcess()");
return;
}
可是不对
pnz_fox 2007-05-06
  • 打赏
  • 举报
回复
跪求是要上下跪照片的 - -#

65,212

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧