Copying integer to integer with allocated memory
13,479
Just dereference anotherInteger
.
*anotherInteger = anInteger;
strncopy
is for strings.
Author by
Fjodor
Updated on June 05, 2022Comments
-
Fjodor almost 2 years
I have a problem with the code below.
... int anInteger; ... //anInteger gets a value ... int *anotherInteger; label = (int *)malloc(sizeof(int)); strncpy(anotherInteger, anInteger, 40);
Essentially what I want to do is to copy the value from an integer to my other integer which I have allocated memory for. Can this work with strncpy between integers or do I need another function?