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 <unistd.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
char *args[] = { | |
"xdg-open", | |
"https://www.youtube.com/watch?v=DLzxrzFCyOs", | |
NULL | |
}; |
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> | |
// C-Style way of obtaining number of elements in | |
// statically sized array. | |
// This is very unsafe! | |
#define SIZEOF_ARRAY(v) (sizeof(v)/sizeof(*v)) | |
// C++-ish way for obtaining the number of array elements. | |
// Safe, cannot be compiled for simple ptr (array-like) types. | |
template<class T, std::size_t N> |
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> | |
int main(int argc, char const *argv[], char const *envp[]) | |
{ | |
int i; | |
char **env; | |
FILE *fp; | |
fp = argc == 2 ? fopen(argv[1], "w") : stdout; | |
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 <assert.h> | |
#include <cstring> | |
#include <algorithm> | |
#include <iostream> | |
#include <type_traits> | |
template<std::size_t N> | |
class label | |
{ |
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 <sys/types.h> | |
#include <sys/socket.h> | |
#include <arpa/inet.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
int sock = socket(AF_INET, SOCK_STREAM, 0); | |
struct sockaddr_in addr; |
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 <malloc.h> | |
struct static_buffer { | |
size_t size; | |
char buffer[0]; | |
}; | |
struct static_buffer* alloc_buffer(size_t size) | |
{ |
NewerOlder