Skip to content

Instantly share code, notes, and snippets.

@jwieder
jwieder / readlink.c
Last active August 29, 2015 14:11
The readlink function gets the value of the symbolic link filename. The file name that the link points to is copied into buffer. This file name string is not null-terminated; readlink normally returns the number of characters copied. The size argument specifies the maximum number of characters to copy, usually the allocation size of buffer.
@jwieder
jwieder / dgb_hash.c
Last active August 29, 2015 14:11
Very simple implementation of a DGB hash function, written in C. Accepts one contiguous string, provided as a command line argument, as input. For example: #./dgb_hash plaintext
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
if (argc != 2)
{
printf("\nCorrect usage is: gdb_script plaintext\n");
return 1;
}
@jwieder
jwieder / linked-list.c
Created December 16, 2014 22:01
Example of linked list creation in C. Note this is merely a struct and function, and does not include a main function or preprocessor imperatives. Used in Harvard's CS50 class.
typedef struct node
{
int n;
struct node *next;
}
node;
bool search(int n, node* list)
{
node* ptr = list;
@jwieder
jwieder / vigenere.c
Last active August 29, 2015 14:10
Simple Vigenere cipher written in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cs50.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
if (argc != 2)
{