Questions tagged as 'c'

1
answer

Problems with gaussian filter application

The function should only apply the Gaussian filter in a PPM image, but the result is several superimposed filtered images. Any suggestions? [edit] before filter image | image after filter | expected result pixel** gauss_filter(pixel**...
asked by 03.11.2017 / 04:39
1
answer

How to pass a struct dynamically allocated to a function in C?

The program should dynamically allocate the struct and pass it as a parameter. #include <stdio.h> #include <stdlib.h> typedef struct cadastro_de_mercadoria{ int codigo; int estoque; } CADASTRO; void printar(CADASTRO cadas...
asked by 02.10.2018 / 04:00
1
answer

Stable vs. unstable ordering

What defines a stable sort algorithm? In this question I've been told a bit about stable and unstable ordering, but I still do not see the advantage of using an unstable one. In what cases can we use unstable ordering? Is it always prefe...
asked by 26.08.2018 / 23:01
1
answer

Wrong result when calculating BMI

I'm doing an exercise with the C language to calculate the BMI, it does not give any error in the compiler but the result goes all wrong, I already looked at the code and did not find the error at all. The code is as follows: #include <s...
asked by 01.06.2017 / 01:47
1
answer

Generate random numbers in C?

I need to generate 5 random numbers in a range between -10 and +10. How could I do this? I've already seen that you can use shuffle , malloc or even realloc , but being new to C, I do not quite understand how I can make it w...
asked by 04.06.2017 / 23:06
1
answer

how to receive input from the user and write to a file

I am trying to receive several lines of input from the user (at most 37 chars each) and write them in a file, but the result is the creation of the file with nothing there. My current code: void escrever_para_ficheiro(FILE *fp){ char bu...
asked by 02.06.2018 / 02:55
2
answers

Read a txt file and place each character in a position of an array in C

I tried the code below but it did not work The big problem is fscanf putting each character of the text in an array position #include <iostream> #include <stdio.h> using namespace std; int main() { int a; char texto[1000]; F...
asked by 15.05.2017 / 05:49
1
answer

How to represent algorithm in C for Pseudocode?

I have the following code: setlocale(LC_ALL,"portuguese"); int numeros[5]; int media; for(int i = 0; i < 5; i++) { printf("Digite um número : "); scanf("%d", &numeros[i]); } media = numeros[0] + numeros[1] + numeros[2] + nume...
asked by 20.05.2017 / 17:21
1
answer

How to leave code in the format of the language inside the word [closed]

I currently have a code in C language. I need to present this code in a job through PDF or .doc. But formatting a code in Microsoft Word to make it the same in the IDE is a lot of work. Is there any tool that I can export the IDE code directl...
asked by 19.12.2017 / 00:45
2
answers

Handler? What is this and what is it for in C / C ++?

There are times when I see lots of code using this HANDLER type. What is it and what is it for? Where I find tutorials that teach you how to use it.     
asked by 08.12.2017 / 05:36