Last active
June 5, 2016 01:32
-
-
Save otaks/70533f443fb700ede9028df645dee5c5 to your computer and use it in GitHub Desktop.
c capcel
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 <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 ); | |
} |
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
#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 ); |
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 "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