-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmental.cpp
More file actions
executable file
·43 lines (35 loc) · 1011 Bytes
/
mental.cpp
File metadata and controls
executable file
·43 lines (35 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* mental.cpp
* This program prints a random quote that promotes mental health or that I
* just like in general. It is intended to be added a shells .*rc file so that
* it can run whenever a new shell is opened. The quotes are retrieved from a
* text file in your home directory called ".quotes" and the format of the
* quotes is seen bellow.
*
* Syntax: Name - "Quote"
*/
#include <fstream>
#include <iostream>
#include <random>
#include <string>
using namespace std;
int main()
{
const string path = ".quotes";
ifstream file;
file.open( path );
vector<string> qVec;
string quote;
if( !file )
{
cout << "There was an issue opening the '.quotes' file. Verify its "
<< "validity/prescence" << endl;
return -1;
}
while( getline( file, quote ) )
qVec.push_back( quote );
file.close();
srand( time( NULL ) );
int random = ( rand() % qVec.size() );
cout << "\n" << qVec.at( random ) << "\n" << endl;
}