Medium
Qualify the following code:
char *p;
p = (char *)malloc (5 * sizeof (char));
strncpy (p, «abcde», 5);
Author: Abha AgrawaStatus: PublishedQuestion passed 257 times
Edit
3
Community Evaluations
Paul Desplanque
27/02/2025
« problème sur la taille allouée ». J'ai pas coché cette réponse.
Alors oui effectivement, dans la plupart des cas on voudra de la place en plus (un octet) pour terminer la chaîne avec un zéro. Sauf que c'est une convention et on peut tout à fait vouloir ne pas le faire, et le code présenté est tout à fait compilable.
1
What does the following code refer to: C:\ProgramFiles\QtCreator\text.txt ? 3
Find the sum of all even numbers in an array in C7
What is the size of a long long in C++?2
Write a C program to calculate the total number of sweets.2
Write a C function to swap two integers.3
Write a C program that calculates the average of two notes.2
Include a .h library in C