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
#include <iostream> // cout, endl; | |
#include <stdio.h> // popen, pclose | |
int main(void) { | |
std::cout << "Caller starts" << std::endl; | |
FILE *fp = popen("./writeTest", "r"); | |
pclose(fp); | |
std::cout << "Caller ends" << std::endl; |
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
#include <iostream> // cout, endl | |
#include <unistd.h> // getpid() | |
#include <stdlib.h> // exit() | |
int main(void) { | |
std::cout << "(First) Process ID is " << getpid() << std::endl; | |
// Create child process | |
int forkReturnValue = fork(); // --- Process forks here! --- |
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
#include <iostream> // cout, endl | |
std::string stringReplace(const std::string target, | |
const std::string from, | |
const std::string to); | |
// First command line argment is target string to replace | |
// Second command line argument is replaced to Third command line argument | |
int main(int argc, char *argv[]) { | |
if (argc != 4) { |
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
#include <iostream> // cout, endl | |
#include <dirent.h> // DIR, opendir, readdir, struct dirent | |
#include <string.h> // strcmp | |
#include <errno.h> // errno | |
#include <stdlib.h> // exit | |
bool checkDirEmpty(std::string targetDir); | |
int main(void) { | |
std::string emptyDirPath = "emptyDir"; |
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
#include<stdio.h> | |
#include<pthread.h> // pthread_create | |
#include<unistd.h> // sleep | |
extern "C" { | |
typedef void* (*ThreadFunc_t)(void*); | |
} | |
class Test { | |
private: |
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
#include <iostream> // cout, endl | |
#include <sys/stat.h> // stat | |
int main(void) { | |
struct stat statFile; | |
struct stat statDirectory; | |
struct stat statNothing; | |
// if file/directory exists, stat() returns 0 | |
// if file/directory does not exist, stat() returns -1 |
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
#include <iostream> // cout, endl | |
#include <cstdlib> // atoi | |
// Convert string (char array) to integer | |
int main() { | |
std::string string123("123"); // This is string | |
// Convert string (char array) to integer using atoi | |
if (std::atoi(string123.c_str()) == 123) { | |
std::cout << "std::atoi(string123.c_str()) is 123(int)" << std::endl; |
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
// This program achieves LED blink on Raspberry Pi with Go lang. | |
// This is implemented with hard-coding and uses only main function. | |
package main | |
import ( | |
"fmt" | |
"os" | |
"time" | |
) |