Giter Site home page Giter Site logo

alperenisa / kedi.h Goto Github PK

View Code? Open in Web Editor NEW

This project forked from afacanc38/kedi.h

2.0 0.0 0.0 12 KB

Dinamik olarak bağlanabilir kitaplık denemeleri, aynı zamanda ilk C projem.

License: Creative Commons Zero v1.0 Universal

C 79.92% Makefile 20.08%

kedi.h's Introduction

kedi.h

Dinamik olarak bağlanabilir kitaplık denemeleri, aynı zamanda ilk C projem.

Çalıştırmak için

make
make run

kedi_cinsi [enum]

enum kedi_cinsi
{
    TEKIR,
    SIYAM,
    DIGER
};

Kedi cinsini belirler.

kedi [struct]

typedef struct kedi
{
    char* ad;
    int yas;
    enum kedi_cinsi cins;
} kedi;
  • ad: Kedinin adını belirtir.
  • yas: Yıl biçiminden kedinin yaşını belirtir.
  • cins: Kedinin cinsini belirtir.

yeni_kedi [function]

kedi* yeni_kedi (char* kedi_adi, int yas, enum kedi_cinsi cins)
{
    kedi *i = malloc(sizeof(kedi));
    i->ad = strdup (kedi_adi);
    i->yas = yas;
    i->cins = cins;

    return i;
}

Bellek yığınında yeni bir kedi oluşturur ve kedinin adresini dönderir.

kedi_bilgi [function]

void kedi_bilgi (kedi *k)
{
    printf ("Adı: %s\n", k->ad);
    printf ("Yaşı: %d\n", k->yas);
    printf ("Cinsi: %s\n", kedi_cins_bul(k));
}

Verilen kedinin kimliğini stdout'a yazdırır.

kedi_cins_bul [function]

char* kedi_cins_bul (kedi *k)
{
    switch (k->cins)
    {
        case TEKIR:
            return "tekir";
        case SIYAM:
            return "siyam";
        default:
            return "diğer";
    }
}

Kedinin cinsini enum'dan char*'a çevirir.

rahat_birak [function]

void rahat_birak (kedi *k)
{
    free (k->ad);
    free (k);
}

Verilen kediyi bellek yığınından temizler. Bunu yapmayı unutmak bellek sızıntılarına yol açabilir.

kedi.h's People

Contributors

alperenisa avatar afacanc38 avatar

Stargazers

 avatar LustyRoosEE avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.