Questions tagged as 'c'

2
answers

Determine how many "islands" an array contains

I need to create a program that receives as input an array size (up to 300 per 300) and the array values that will be stored (it can be only 1 or 0). I must determine the number of "islands" (clusters of 1) formed and display for the user. I can...
asked by 14.10.2017 / 06:03
2
answers

Separate integer by character

I have a vector of integers: int nums[10] = { 1234, 4761814, 9161451, 14357 }; I want to know how to separate these numbers, for example, the first element turns a vector like this: {1, 2, 3, 4} ie separate the integer, becaus...
asked by 08.10.2015 / 05:30
1
answer

Use a void function as parameter of another

Suppose I need a function to run to a certain point, call another, do some action, call another function, do one more action and finish executing. Whereas the called functions are given a parameter but give no return to the first. Ex: void com...
asked by 22.09.2015 / 18:27
2
answers

Dynamic allocation and runtime of functions

When we use some of the C dynamic allocation functions (malloc, calloc, realloc etc) inside a function that is called by main, will the memory remain allocated at the end of the execution of this function or will it automatically be deallocated?...
asked by 17.09.2015 / 15:50
1
answer

Meaning of (void *)

What does it mean to call a function with one that was int and is passed as (void *) ? If the variable was declared as int because it is passed as a parameter to a *(void *)variavel* function? Example int var =...
asked by 20.05.2014 / 21:26
1
answer

What is segmentation fault?

This error often occurs with faulty codes. I do not see it occurring in other languages. Why does it occur? What does it mean?     
asked by 13.01.2017 / 11:31
1
answer

Is it possible to initialize only some members of an array in C already in its definition?

I know you can do this: int a[5] = { 0, 3, 8, 0, 5 }; or int a[5]; a[1] = 3; a[2] = 8; a[4] = 5; Can you do the same in just one line, already in the definition?     
asked by 22.03.2017 / 12:33
1
answer

Recursive analysis of a vector

QUESTION: Write a recursive function that parses the elements of a vector and returns one of the following codes: 0 Disordered elements 1 Items sorted in ascending order 2 Constant elements 3 Items ordered in descending order int A...
asked by 04.10.2015 / 15:37
1
answer

How to insert dynamically into a std :: array?

I'm migrating from C language to C ++, and I want to stop using traditional C language media as the vector of it. Is it possible to use std::array to insert elements dynamically as in std::vector ?     
asked by 08.11.2016 / 15:52
1
answer

Start structure pointer with an address?

I would like to know if it is possible to start this pointer type structure with an address, without needing to point to another variable, or allocate memory. typedef struct{ char nome[20]; int idade; }pessoa; pessoa leonardo; pess...
asked by 28.09.2016 / 15:09