malloc « byte « C Data Type Q&A

Home
C Data Type Q&A
1.binary
2.bit
3.byte
4.char
5.character
6.decimal
7.Development
8.float
9.hex
10.integer
11.prime
12.random
13.struct
C Data Type Q&A » byte » malloc 

1. Why does malloc allocate a different number of bytes than requested?    stackoverflow.com

I have this piece of code

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

int main(){
void *a, *b;

a=malloc(16);
b=malloc(16);
printf("\n   block size (for a): %p-%p : %li",b,a,b-a);

a=malloc(1024);
b=malloc(1024);
printf("\n   block size (for a): %p-%p : %li",b,a,b-a); ...

2. Is there a way to find out what the maximum number of bytes available is when using malloc in c?    stackoverflow.com

Or do you just have to do it and check errno and/or the pointer to see if you succeeded?

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.