This file contains hidden or 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
#include <iostream> | |
#include <sstream> | |
using namespace std; | |
int main(int argc, char *argv[]) { | |
bool b = true; | |
// High school level | |
if (true) { | |
cout << "simple conditional" << endl; | |
} |
This file contains hidden or 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
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <math.h> | |
#include <cstdio> | |
#include <memory> | |
#include <stdexcept> | |
#include <fstream> |
This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
string exec(const char* cmd); // Used for executing terminal commands in c++ | |
string getPassword(); // Prompts the user for their system password and checks to see if it is the correct password | |
// If the password is correct, it returns it in a string | |
int main(int argc, char *argv[]) { // Example implementation of getPassword() |
This file contains hidden or 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
# Prompts user for password until the password is correct | |
# Useful for programs where you must get the correct password from the user in order to execute a command | |
passOk="false" | |
while [ "$passOk" != "true" ] | |
do | |
echo -n "Password: " | |
read password # Grabs username | |
if [[ $(echo $password | sudo -k -S echo valid) = "valid" ]] &>/dev/null; then | |
echo "Correct password" |
NewerOlder