Skip to content

Instantly share code, notes, and snippets.

@corydolphin
Created April 10, 2014 16:08

Revisions

  1. Cory Dolphin created this gist Apr 10, 2014.
    36 changes: 36 additions & 0 deletions example.diff
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    < /*
    < Exam 2
    < Cory dolphin
    ---
    > /* Example code for Software Systems at Olin College.
    >
    > Copyright 2014 Allen Downey
    > License: Creative Commons Attribution-ShareAlike 3.0
    9d9
    < #include "stdlib.h" // we need malloc!
    20c20
    < vector->data = calloc(len, sizeof(double *)); // calloc takes a (size_t num, size_t size)
    ---
    > vector->data = calloc(len * sizeof(double *));
    27d26
    < free(vector->data); //we need to free the data before we free the struct!
    28a28
    > free(vector->data);
    69,71c69,71
    < // Adds two vectors elementwise and returns a new vector. And the call signature was wrong
    < Vector *add_vector_func(Vector *A, Vector *B) {
    < Vector *C = make_vector(A->len); //we need to make a new vector and return it
    ---
    > // Adds two vectors elementwise and returns a new vector.
    > double *add_vector_func(Vector *A, Vector *B) {
    > Vector *C = make_vector(A->len);
    73d72
    < return C;
    76c75
    < int main() {
    ---
    > int main {
    95c94
    < return 0; // semicolons are hard to find
    ---
    > return 0