使用cmd读取文件并插入C ++

时间:2018-12-23 01:26:55

标签: c++ batch-file cmd

我需要有关此任务的帮助

1)File.bat将打开用c ++编写的program.exe

2)使用.bat,我需要从文件夹数据中的3-4个文件中读取数据,然后将其插入到我的c ++文件中。

3)当程序停止计算时,我需要将结果插入文件夹输出中的.txt文件中。

文件示例

文件夹数据

Data1.txt

0, 0, 20, 0, 10, 30, 10, 15
there will be more under

Data2.txt

4, 2, 10, -4, 10, 20, 0, -300
there will be more under

下面的程序将检查点是在三角形内还是在外部

Program.exe

#include < bits / stdc++.h >
  using namespace std;
float wspolrzedne(int x1, int y1, int x2, int y2, int x3, int y3) 
{
  return abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0);
}

bool wewnatrz(int x1, int y1, int x2, int y2, int x3, int y3, int x, int y) 
{
  float A = wspolrzedne(x1, y1, x2, y2, x3, y3);
  float A1 = wspolrzedne(x, y, x2, y2, x3, y3);
  float A2 = wspolrzedne(x1, y1, x, y, x3, y3);
  float A3 = wspolrzedne(x1, y1, x2, y2, x, y);
  return (A == A1 + A2 + A3);
}

int main() 
{
  if (wewnatrz(input.txt))
    printf("Inside");
  else
    printf("Outside");
    insert into output.txt
  return 0;
}

文件夹输出

Output1.txt

Inside
there will be more under

Output2.txt

Outside
there will be more under

bat文件

@echo off
:menu
cls
echo ========MENU=======
echo === 1. Start   ====
echo === 2. Info    ====
echo === 3. Backup  ====
echo === 4. Exit    ====
echo ===================
set /p select="Select 1,2,3,4: "
IF %select%==1 goto opt1
IF %select%==2 goto opt2
IF %select%==3 goto opt3
IF %select%==4 goto exit

:opt1
echo Data from files will be collected and processed.
????????
pause
goto menu
:opt2
echo This program checks if point is in or outside triangle
pause
goto menu
:opt3
echo Your backup is on the way
Xcopy  %cd%  %cd%\Backup  /M /E /G /H /Y
pause
goto menu
:exit
echo Bye!
pause

我该如何连接所有这些?我不知道。

0 个答案:

没有答案