dynamic-allocation tag

9 questions


2 answers
156 views
0
How to Use For Statements Using C++ Auto

int * buff = new int[10];for(auto x : buff?? ){ x = 0;}I want to initialize all the buffs that were assigned dynamically to zero, buff?Please tell me how to write down.I tried buff[], buff, etc., but ...


1 answers
118 views
0
Data search question in C language binary search.

#include<stdio.h>#include<stdlib.h>int idxsearch(int ar[], int first, int last, int target) { int mid = (first + last) / 2; if (first > last) return -1; else { if (ar[mid] == target) ...


1 answers
114 views
0
Problem occurs with dynamic deallocation of C language pointer secondary array.

#include stdio.h#include stdlib.h unsigned int Node_size; float Mean_degree; int (*bin)[2] , i , j , k=0 , l=0; printf(Node size :?); scanf(%d,&Node_size); printf(Mean degree :?); scanf(%f,...

2 years ago

1 answers
139 views
0
To output decimals

int main(void){ int num = 0; int* a = NULL; printf(>Positive Input : ); scanf(%d, &num); a = (int*)malloc(num-2); search(a,num); for (int i = 0; i < num-2; i++) { if(a[i-2] == 0) printf(X )...


1 answers
155 views
0
Ask about printing strings using the C language recursive function.

If you output a string of length 3 using two alphabets ab, aaaaababaabbbaababbbabbbYou have to make it come out like this.A two-dimensional character array is dynamically assigned, and the Distr funct...


2 answers
85 views
0
C Dynamic Allocation Why can I modify or access memory that I released with free()?

#include <stdio.h>#include <stdlib.h>int main(void) { int *pList = NULL, i = 0; pList = (int*)malloc(sizeof(int) * 3); pList[0] = 10; pList[1] = 20; pList[2] = 30; for(i=0; i <3; ++i) {...

2 years ago

1 answers
142 views
0
[C question] How should I release the dynamic allocation in this situation?

#include <stdio.h>#include <stdlib.h>char *Mystrrev(char *string) { int nLength = 0; char *Mystr = NULL; for(int i = 0; string[i] != '\0'; i++) nLength++; Mystr = (char*)calloc(nLength + 1...


2 answers
86 views
0
C++ Dynamic Assignment Structure Pointer, question for use with other functions

Hi, everyone.I made a simple code. I'd like to hear advice from experts who know the problem.#include <iostream>using namespace std;int CountPlayer;struct SUTDA{ char Name[20];};void Input(){ co...


1 answers
127 views
0
When you dynamically assign a C language array...

#include <stdio.h>int main(){ int * arr1 = (int *)malloc(sizeof(int) * 6); int * arr2 = (int *)malloc(sizeof(int) * 6); int * arr3 = (int *)malloc(sizeof(int) * 6); arr1[3][2] = { {3, 4}, {5, ...


© 2024 OneMinuteCode. All rights reserved.