Hur wrote:
> hi i ask two questions......someone can tell me
>
> i an a linux gcc user and wanna know that
>
> - how much physical memory is used for my c code ?
>
As your C code gets compiled into assembler code and then
into machine code, and as the program gets loaded into memory,
the size of your c code == size of the machine code == size of .text
segment of your program + ((size of the machine code) mod (memory
alignment))
> and another one is
>
> - i need a (standard) function to count the number of '1'
> for example,
> 1010 1000 0000 0000 ====> 3
> 0000 0000 1111 0000 ====> 4
No such thing as standard way for counting number of 1 bits in byte.
Here is nice way:
int
cb(unsigned x)
{
x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x & 0x0f0f0f0f) + ((x >> 4) & 0x0f0f0f0f);
x = (x & 0x00ff00ff) + ((x >>

& 0x00ff00ff);
x = (x & 0x0000ffff) + ((x >> 16) & 0x0000ffff);
return x;
}
P.Krumins