C.SelfReferentialStructureExample1 History
Hide minor edits - Show changes to markup
September 03, 2005, at 05:37 PM
by �zg�n
Added lines 1-40:
Self referential structure �rneği.
(:code lang=c:)
/**
* Program: self_referential_structure.c
* Aciklama: Icinde kendini gosteren bir structure bulunan structure ornegi.
* Kaynaklar:
* 1- C How to Program, Deitel
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main (int argc, char *argv[]) {
// Dugum(node) bildirimi.
// Node = Veri(date) + Bag bilgisi(nextPtr)
struct node {
int data;
struct node *nextPtr;
};
// Bag bilgisini tutacak pointer i�in bellekten yer alinir.
struct node *newPtr;
newPtr = malloc(sizeof(struct node));
printf("%d \n", sizeof(int) );
printf("%d \n", sizeof(struct node));
// Belekten aldigimiz yeri iade edelim ki borclu gitmeyelim
free(newPtr);
printf("\n --------------- Biti --------------\n");
return 0;
} //main() sonu.