-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better Organised Compiled for both MacOS and Windows Accept Destination as Argument
- Loading branch information
Showing
8 changed files
with
55 additions
and
36 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Compiling on Windows with MinGW | ||
|
||
set PATH=C:\mingw\bin;%PATH%; | ||
gg++ shendmail.cpp -o shendmail.exe |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* Platform | ||
================================================ | ||
This works as is on MacOS and Linux. | ||
If you are using Windows the #ifdef below should | ||
detect it, and the POSIX function realpath() is | ||
faked with the Windows function _fullpath() | ||
================================================ */ | ||
#ifdef _WIN32 | ||
#define realpath(N,R) _fullpath((R),(N),_MAX_PATH) | ||
#endif | ||
|
||
// Includes | ||
|
||
#include <fstream> | ||
#include <string> | ||
#include <iostream> | ||
#include <stdio.h> | ||
#include <libgen.h> | ||
|
||
using namespace std; | ||
|
||
// main | ||
|
||
int main(int argc, char *argv[]) { | ||
// CWD | ||
char buffer[FILENAME_MAX]; | ||
realpath(argv[0],buffer); | ||
string cwd=dirname(buffer); | ||
|
||
// cout<<cwd<<"\n"; | ||
|
||
// Define Input | ||
string input; | ||
|
||
// Define Output | ||
string outputFile=cwd+"/mail.txt"; | ||
if(argc>1) outputFile=argv[1]; | ||
ofstream output; | ||
output.open(outputFile,ofstream::out | ofstream::app | ofstream::binary); | ||
|
||
// cout<<outputFile<<"\n"; | ||
|
||
// Do the thing … | ||
while(getline(cin,input)) { | ||
output<<input; | ||
output<<"\n"; | ||
} | ||
output<<"================================================\n\n"; | ||
|
||
return 0; | ||
} |
File renamed without changes.