C problem...se megethos domhs
John Tsiombikas (Nuclear / the Lab)
nuclear at siggraph.org
Sat Jan 24 18:05:33 EET 2004
Someone wrote:
> 1) o tupas pou egraspe ton kodika bazei os 2o orisma sthn fseek (poso
> tha metakinhthei apo thn SEEK_END) to 0L ...exei kaneis kamia idea
> giati den bazei to 0? Kai allou ton eida na arxikopoiei se -1L...
0L simenei ena long int me tin timi 0, pantos den einai aparetito, o compiler
tha dei peri tinos prokeite efoson yparxei to prototype tis fseek kai tha balei
tin katalili timi (0L) akoma kai an grapseis apla 0.
> 2) to megethos ths domhs mou tha eprepe na einai 53bye (3 pinakes *15
> xarakthres o kathenas = 45 kai 4 bytes kathe akeraios (2*4=8)...45+8=53
> alla to programma mou gurna megethos 56!!. An afaireso tous 2 akeraious
> apo to telos ths domhs tha paro apotelesma 45 (3pinakes *15). An pali
> afaireso ton 1 akeraio tha paro apotelesma 52 eno tha eprepe na paro
> 45+4=49).. Auto pou me dokimes brhka einai oti an exo tous pinakes
> xarakthron kai toulaxiston 1 akeraio meta xrhsimopoiei 1 byte (gia kathe
> pinaka pou exo) epipleon...kapos san na tous diaxorizei..exei kaneis
> kamia idea giati ginete auto?
o compiler prosthetei padding sta structs gia na ferei to addressing se 4byte
boundary synithos, gia na kanei optimized memory access. Den einai aparetito to
footprint stin mnimi (kai antistixa sto arxeio pou grafeis) enos struct na einai
akrivos to arthroisma ton melon tou.
btw yparxei nomizo compiler option ston GCC pou anagkazei ton compiler na min
bazei padding sta arrays alla de thymame pos to lene, man gcc.
> sas paratheto ton kodika...
> 1000 euxaristo
> btw an kapoios kserei kanena ellhniko h kalo kseno newsgroup gia c h
> ellhniko forum gia c programming as mou pei plz..
comp.lang.c
> main(){
ayto kalytera na to diloneis:
int main(void)
ta implicit ints kai ta unchecked argument lists einai ligo bad style.
>
> FILE *f;
>
> int sizerec;
> long lengthf;
>
> f=fopen("test.dat","w+");
ti ginete an apotyxei? panta check gia NULL stin fopen
-- Nuclear / the Lab --
More information about the Linux-greek-users
mailing list