Skip to content

Instantly share code, notes, and snippets.

View ibaned's full-sized avatar

Dan Ibanez ibaned

  • Sandia National Laboratories
  • Albuquerque, NM
View GitHub Profile
@ibaned
ibaned / copy_by_cd.c
Created April 22, 2012 14:53
copying file between directories without pathname manipulation
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#define CALL(f) assert(0==(f))
#define PCALL(f) assert(NULL!=(f))
#define BUFFER_SIZE 256
//this program copies dir1/filename to dir2/filename
@ibaned
ibaned / string_array.c
Created April 21, 2012 00:29
functions for handling arrays of strings
char* create_string_buffer(unsigned number_of_strings, unsigned max_string_length)
{
return (char*) malloc(number_of_strings*max_string_length);
}
void copy_string_into_buffer(char* buffer, unsigned index, unsigned max_string_length, char* string)
{
strncpy(buffer + (max_string_length*index), string, max_string_length);
}