Skip to content

Instantly share code, notes, and snippets.

@otaks
Last active June 5, 2016 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save otaks/70533f443fb700ede9028df645dee5c5 to your computer and use it in GitHub Desktop.
Save otaks/70533f443fb700ede9028df645dee5c5 to your computer and use it in GitHub Desktop.
c capcel
#include <stdlib.h>
#include "dog.h"
struct dog {
char name[ 20 ];
};
Dog Dog_create( char* name ) {
Dog t = calloc( sizeof( struct dog ) ,1);
memset( t->name, 0x00, sizeof( t->name ) );
strcpy( t->name, name );
return t;
}
void Dog_berg( Dog dog )
{
printf( "wan!!\n" );
}
void Dog_sayName( Dog dog ) {
printf("%s\n", dog->name );
}
void Dog_delete( Dog dog ){
free( dog );
}
#pragma once
#include <stdio.h>
typedef struct dog* Dog;
//クラス定数
//#define AAA 1
//クラス変数
//int i;
Dog Dog_create( char* );
void Dog_berg( Dog );
void Dog_sayName( Dog );
void Dog_delete( Dog );
#include "dog.h"
int main() {
Dog one = Dog_create("lewis");
Dog two = Dog_create( "mike" );
Dog_sayName( one );
Dog_sayName( two );
Dog_delete( one );
Dog_delete( two );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment