I'm very new at C++: I'd like to put part of the source code in to another source file and be able to execute the source of the second file by calling it out from the first file, is this even possible? I appreciate some guidance.
The following sample program output an X to a random location at the Linux console.
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <chrono> //slow down
#include <thread> //slow down
using namespace std;
void gotoxy(int x,int y)
{
printf("%c[%d;%df",0x1B,y,x);
}
int main()
{
int x=1;
int y=1;
int b=1;
for (;;) { // I'd Like this Loop execution in a separate source File
gotoxy (1,40);
cout << "X =" <<x <<endl;
cout << "Y =" <<y <<endl;
x = rand() % 30 + 1;
y = rand() % 30 + 1;
for (int b=0 ;b<10000;b=++b){
gotoxy (x,y);
cout << " X ";
cout <<"\b \b"; // Deletes Just Printed "X"
}
}
}