Tahák pro Céčko
Vložil admin, Út, 2009-12-01 09:29
C
Jak co napsat v Céčku aby to fungovalo jak bylo zamýšleno.
C
Jak co napsat v Céčku aby to fungovalo jak bylo zamýšleno.
Komplexní deklarace ------------------- type name; typ int count; type name[]; (otevřené) pole typů int count[]; type name[n]; char text[]= "Test"; char text[]= {"Test"}; type *name; pointer na typ int *count; void *ptr=NULL; char *text = "Test"; type *name[]; pole pointerů na typ int *count[]; type *(name[]); char *name[]= {"Test1", "Test2"}; type (*name)[]; pointer na pole typů int (*count)[]; type *(*name)[]; pointer na pole pointerů int *(*count)[]; na typ type name(); funkce vracející typ int count(); void proc(void); type *name(); funkce vracející pointer int *count(); type *(name()); na typ char *getText(); type (*name)(); pointer na funkci vracející int (*count)(); typ type *(*name)(); pointer na funkci vracející int *(*count)(); pointer na typ const type *name pointer na konstantu char const *p type * const name konstantní pointer na proměnnou char * const p; const type *const name konstantní pointer na const char *const p konstantní proměnnou const type (*const p)[] konstantní pointer na pole const char (* const p)[3] konstant const type *const type[] konstantni pole pointerů na const char * const p[8] konstantu type class_name::*name ukazatel na datový prvek třídy definice: int c::*p; int c::*p=&c::fld; užití: cinst.*p=123456; type (class_name::*name)(type) ukazatel na členskou funkci definice: void (c::*p)(int); void (c::*p)(int)=&c::func; užití: (cinst.*p)(123456); Pointer conversion ------------------ (type *) konvertuje pointer na typ "pointer na typ" char *str; int *ip; str = (char *)ip; Funkce ------ int f(); styl K&R, žádná informace o parametrech int f(void) funkce bez parametrů Struktury --------- struct mystruct {}; // tagged structure struct mystruct s, *ps, arrs[10]; struct {} s, *ps, arrs[10]; typedef struct mystruct {} MYSTRUCT; nebo typedef struct {} MYSTRUCT; MYSTRUCT *ps, arrs[10], s = { .a = 2 }; Uniony ------ union myunion { int i; double d; char ch; } mu, *muptr=&mu, mu2= {12}; Enumeration ----------- enum days {sun=1, mon, ...} anyday; enum days day1, day2; anyday = sun; enum {sun, mon, ...} anyday // untagged
» Přihlašte se, abyste mohl psát komentáře | 3238 x přečteno