Skip to content

Instantly share code, notes, and snippets.

@heronyang
Created August 3, 2019 20:34
Show Gist options
  • Select an option

  • Save heronyang/f5445d7f147bef0a8612397cbdebc3c2 to your computer and use it in GitHub Desktop.

Select an option

Save heronyang/f5445d7f147bef0a8612397cbdebc3c2 to your computer and use it in GitHub Desktop.
/* labeledPoint.c */
#include "labeledPoint.h"
#include <stdlib.h>
struct LabeledPoint {
double x, y;
char* name;
};
struct LabeledPoint* makeLabeledPoint(double x, double y, char* label) {
struct LabeledPoint* p = malloc(sizeof(struct LabeledPoint));
p->x = x;
p->y = y;
p->name = name;
return p;
}
void setLabel(struct LabeledPoint* lp) {
lp->name = name;
}
char* getLabel(struct LabeledPoint* lp) {
return lp->name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment