malloc



Defined in header - stdlib.h

void* malloc( size_t size);

Allocates size bytes of uninitialized storage.

If allocation succeeds, returns a pointer to the lowest (first) byte in the allocated memory block that is suitably aligned for any object type


Parameters

size - number of bytes to allocate.


Return value

On success, returns the pointer to the beginning of newly allocated memory. The returned pointer must be deallocated with free() or realloc() to avoid memory leaks after usage.
On failure, returns a null pointer.


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

int main( int argc, char* argv[])
{
	char * str = (char *) malloc( (sizeof(char) * 100));
	
	if(!str)
	{
		printf("memory allocation failed!\n");
	}
	
	return EXIT_SUCCESS;
}

The above program allocates 100 char memory, and returns pointer to the allocated block.




strtok

Split string into tokens

posted on 2019-03-17 20:41:48 - C Programming Language Tutorials


zalloc

zalloc is a third party library

posted on 2018-12-12 20:46:30 - C Programming Language Tutorials


math

posted on 2017-12-29 22:52:47 - C Programming Language Tutorials


Prompt Examples

ChatGPT Prompt Examples

posted on 2023-06-21 22:37:19 - ChatGPT Tutorials


Use Cases

Chat GPT Key Use Cases

posted on 2023-06-21 21:03:17 - ChatGPT Tutorials


Prompt Frameworks

Prompt Frameworks

posted on 2023-06-21 19:33:06 - ChatGPT Tutorials