#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: There are a bunch of errors in spacy, which never makes sense until you get to the depth of it. In this post, we will analyze the attribute error E046 and why it occurs. (1) AttributeError: [E046] Can't retrieve unregistered extension attribute 'tag_name'. Did you forget to call the set_extension method? Let's first understand what the error means on superficial level. There is a tag_name extension in your code. i.e. from a doc object, probably you are calling doc._.tag_name. But spacy suggests to you that probably you forgot to call the set_extension method. So what to do from here? The problem in hand is that your extension is not created where it should have been created. Now in general this means that your pipeline is incorrect at some level. So how should you solve it? Look into the pipeline of your spacy language object. Chances are that the pipeline component which creates the extension is not included in the pipeline. To check the pipe eleme...
Comments
Post a Comment