Re: pure void* memset(return void* s, int c, size_t n)?

2017-09-06 Thread Uknown via Digitalmars-d-learn
be something like this: pure void * memset(return void * s, int c, size_t n) { foreach (i; 0 .. n) (cast(char *) s)[i] = cast(char) c; return s; }

pure void* memset(return void* s, int c, size_t n)?

2017-09-06 Thread Psychological Cleanup via Digitalmars-d-learn
What is the return doing there?

Re: int or size_t ?

2011-05-08 Thread Stewart Gordon
On 07/05/2011 18:09, %u wrote: In Patterns of Human Error, the slide 31 point that you should replce int with size_t why that consider an error ? For those who aren't sure what this is on about: http://www.slideshare.net/dcacm/patterns-of-human-error But the short answer is because dim

int or size_t ?

2011-05-07 Thread %u
In Patterns of Human Error, the slide 31 point that you should replce int with size_t why that consider an error ?

Re: int or size_t ?

2011-05-07 Thread bearophile
%u: In Patterns of Human Error, the slide 31 point that you should replce int with size_t why that consider an error ? If T is a byte and the array size is 5 billion items, on 64 bit systems...? In the little find() function you compare it with the length, that's a size_t. Someone else

Re: int or size_t ?

2011-05-07 Thread Andrej Mitrovic
void main() { size_t val = int.max+1; int val2 = val; writeln(val2); } writes -2147483648 That should give you a hint.

Re: int or size_t ?

2011-05-07 Thread %u
size_t val1 = int.max+1; int val2 = int.max+1; writeln(val1); // 2147483648 writeln(val2); // -2147483648 very clear example thanks you both

Re: int or size_t ?

2011-05-07 Thread Andrej Mitrovic
definitions in object_.d: version(X86_64) { alias ulong size_t; alias long ptrdiff_t; alias long sizediff_t; } else { alias uint size_t; alias int ptrdiff_t; alias int sizediff_t; } And an example: void main() { size_t val = size_t.max;// maximum unsigned 32bit

Re: int or size_t ?

2011-05-07 Thread Andrej Mitrovic
Edit: I just saw you've already figured this out. :)