Skip to content

Instantly share code, notes, and snippets.

@corydolphin
Created April 10, 2014 16:08
Show Gist options
  • Save corydolphin/10397908 to your computer and use it in GitHub Desktop.
Save corydolphin/10397908 to your computer and use it in GitHub Desktop.
< /*
< 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment