Created
August 2, 2014 22:27
-
-
Save Pavelovich/9dd62924417e790c7881 to your computer and use it in GitHub Desktop.
An example object I created
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
//#include <unistd.h> | |
#include "lib/stdfn.h" | |
typedef struct car { | |
char *color; | |
char *size; | |
int year; | |
} *car_t; | |
car_t newCar(char *color, char *size, int year) | |
{ | |
car_t car = malloc(sizeof(*car)); | |
car->color = color; | |
car->size = size; | |
car->year = year; | |
return car; | |
} | |
char* carColor(car_t car) | |
{ | |
return car->color; | |
} | |
int main(int argc, char *argv[]) { | |
car_t toyota = newCar("red", "big", 2000); | |
char *toyotaColor = carColor(toyota); | |
printf("%s", toyotaColor); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment