Questions tagged as 'c'

1
answer

Pointers in college

I am studying pointers and this is code used as an example that is in the material given by the faculty. I have been replicating this code in my machine and the output is different from the one presented in the material. Code: #include <std...
asked by 29.10.2017 / 00:08
1
answer

What do the following lines of code do?

I have this code: Arvore* arv_insere (Arvore* arvore, Registro* registro){ if (arvore == NULL){ printf(COLOR_RED "ERROR: Arvore não inicializada" COLOR_RESET "\n"); exit(1); } float direction = reg_compare(...
asked by 29.10.2017 / 02:35
2
answers

C Cast vs C ++ Cast

What is the difference between using the cast of C: float t = 5.0f; int v = (int)t; For the C ++ cast: float t = 5.0f; int v = static_cast<int>(t);     
asked by 06.10.2017 / 14:34
1
answer

Run-time error in pthreads

My function main was thus (% with% was set further back): int main() { int i; int *result; pthread_t tid[N]; for (i=0; i<N; i++) { if (pthread_create (&tid[i], 0 ,fnThread, (void*)(&i)) != 0){ printf("Er...
asked by 01.10.2017 / 12:01
1
answer

How to make my code read in UTF-8 in C?

When I run this code: #include <stdio.h> int main(void) { int teste[10]; printf("Imprimindo o vetor 'teste': %d\n", teste); printf("O endereço do primeiro elemento é: %d\n", teste[0]); return 0; } The letters "é" and "ç" com...
asked by 29.09.2017 / 16:41
1
answer

How can I print the fifth part of a real number?

How could I print the fifth (index 4 from the dot) part of a real number without using libraries or a "complex" code for opening chapters. Make a program that reads a real number, and print the fifth part of that number.
asked by 13.10.2017 / 14:00
1
answer

Vector of char by reference

I'm trying to pass a array from char to a procedure that will resize (with malloc() ), write its contents and return to main() . I know that every vector is a pointer and is already passed by reference, but something in...
asked by 01.11.2017 / 18:03
1
answer

Break text and store in vector

I want the program to store only 1 sentence per line. Since each sentence is possible to be terminated according to the signs I show in my code example. It does this but when you print on the screen it does not print those same characters which...
asked by 10.11.2017 / 19:56
1
answer

Problems with recursion in c

I'm trying to learn recursion and am in doubt on an issue I was doing in c, I need to add how many numbers of a vector with n elements are larger than a number x. This recursion simply does not go into the head, I need a clearing. #include <...
asked by 11.11.2017 / 13:27
1
answer

Variable int changes value when reading a variable char

I'm doing a simple hangman game. However, when I read the letter (either with gets or with scanf ), the number of lives drops to 0. I am using Dev-C ++ because it is the program that the teacher uses in class. > int main() { i...
asked by 12.11.2017 / 04:37