#include <stdio.h>
#include <stdlib.h>
int main()
{
int* ptr;
int* ptr1;
int n; int i;int sum = 0;
n = 5;
printf("Number of elements: %d", n);
ptr = (int*)malloc(n * sizeof(int));
ptr1 = (int*)calloc(n, sizeof(int));
if (ptr == NULL || ptr1 == NULL)
{
printf("\nMemory not allocated.");
}
else
{
printf("\n\nMemory successfully allocated using malloc.");
for (i = 0; i < n; ++i)
{
ptr[i] = i + 1;
}
printf("\nThe elements of the first array (using malloc)
are: ");
for (i = 0; i < n; i++)
{
printf("%d ", ptr[i]);
}
printf("\nThe elements of the second array (using calloc")
are: ");
//showing that calloc introduces with 0
for (i = 0; i < n;i++)
{
printf("%d ", ptr1[i]);
}
//section 2
n = 12;
printf("\n\nnumber of elements in the first pointer : %d",
n);
//reallocation usage
int *ptr_new;
ptr_new =(int *)realloc(ptr,sizeof(int)*n ); //observe how
it works like calloc
printf("\nMemory successfully re-allocated using realloc.");
for (i = 5; i < 10;i++)
{
ptr_new[i] = i + 1;
}
printf("\nThe elements of the first array are: ");
for (i = 0; i < 10; i++)
{
printf("%d, ", ptr_new[i]);
}
//usage of free, literally frees up the memory assigned to the pointer
free(ptr_new);
printf("\n\nMalloc Memory successfully freed.");
free(ptr1);
printf("\n\nCalloc Memory successfully freed.");
}
return 0;
}
Introduction: Recently I got access to OpenAI API beta. After a few simple experiments, I set on creating a simple test project. In this project, I will try to create good tinder bio for a specific person. The abc of openai API playground: In the OpenAI API playground, you get a prompt, and then you can write instructions or specific text to trigger a response from the gpt-3 models. There are also a number of preset templates which loads a specific kind of prompt and let's you generate pre-prepared results. What are the models available? There are 4 models which are stable. These are: (1) curie (2) babbage (3) ada (4) da-vinci da-vinci is the strongest of them all and can perform all downstream tasks which other models can do. There are 2 other new models which openai introduced this year (2021) named da-vinci-instruct-beta and curie-instruct-beta. These instruction models are specifically built for taking in instructions. As OpenAI blog explains and also you will see in our
Comments
Post a Comment