What do you want to save?
Add Code snippet
New code examples
-
Other 2022-03-27 21:20:24
realloc
int ptr_new = *realloc(void *ptr, size_t size); Where 'ptr_new' is the new pointer you want to point to the required Dynamic memory, 'ptr' is the already existing pointer to a dynamic memory and 'size' is the new size of dynamic memory that you want to a... Add solution -
Other 2021-11-20 07:40:20
how to print the file content each line in c
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 5 int main(void) { 6 // ... 7 8 // "Empty" the string 9 line[0] = '\0'; 10 11 while(fgets(chunk, sizeof(chunk), fp) != NULL) { 12 ... Add solution -
Other 2021-10-02 19:55:05
why string builder
StringBuilder is for, well, building strings. Specifically, building them in a very performance way. The String class is good for a lot of things, but it actually has really terrible performance when assembling a new string out of smaller string parts be... Add solution -
C++ 2021-09-25 23:39:02
C++ Vector swap syntax
vector<T>().swap(x); // clear x reallocating Add solution -
C++ 2021-09-14 18:46:02
joining two vectors in c++
// my linkedin : https://www.linkedin.com/in/vaalarivan-prasanna-3a07bb203/ vector<int> AB; AB.reserve(A.size() + B.size()); // preallocate memory AB.insert(AB.end(), A.begin(), A.end()); AB.insert(AB.end(), B.begin(), B.end()); //eg : A = {4, 1}, B... Add solution -
C 2021-08-29 17:56:01
increase size of array in c
#include <stdio.h>#include <stdlib.h>int main(){//a pointer to dynamically allocated memory from the heap is returned. int *a = (int *) malloc(20 * sizeof(int));for(int i = 0; i < 20; i++)a[i] = i + 1;printf("\nThe contents of the arra... Add solution