0

I need help with this task

1) File.bat will open program.exe written in c++

2) Using .bat i need to read data from 3-4 files in folder data, then insert it into my c++ file.

3) When program stops calculating i need to insert results to the .txt files in folder output.

Example of files

Folder Data

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 below will check if point is in triangle or outside

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;
}

Folder output

Output1.txt

Inside
there will be more under

Output2.txt

Outside
there will be more under

bat file

@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

How i can connect it all? I don't have idea.

  • 1
    Recommendation: Burn whatever you are using as a C++ programming reference and replace it with [a good beginners book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). Once you have worked your way through the first few chapters of this book return to this problem. – user4581301 Dec 23 '18 at 01:31
  • **Recommended reading:** _[Why should I not #include ?](https://stackoverflow.com/q/31816095/560648)_ – Lightness Races in Orbit Dec 23 '18 at 01:41
  • Your batch file never executes your executable. – Squashman Dec 23 '18 at 03:06
  • 1
    I suggest not using `set /P` for a choice menu, use the command `choice` which is designed for such tasks. For more details see [How to stop Windows command interpreter from quitting batch file execution on an incorrect user input?](https://stackoverflow.com/a/49834019/3074564) But I do not really understand why a batch file is used at all. You wrote an executable in C++. Everything done in the batch file can be also done with C++ code much better and faster. So there is no need for a batch file at all in my point of view. – Mofi Dec 23 '18 at 16:06
  • Because profesor said we have to use batch as menu and programm in c++ – gouran21 Dec 25 '18 at 23:48

0 Answers0