Questions tagged as 'c'

1
answer

You are not generating the 1000 random numbers required

I'm developing a program in C that randomly generates a thousand numbers and that in the end appears the largest and smallest of them. For this, I'm using rand() . But I have a problem. When I run only less than 300 numbers are generate...
asked by 05.11.2014 / 22:06
3
answers

Code to invert sequence of non-vowels ending with zero status

I'm implementing the decodificar function, which aims to call auxiliary functions to invert all non-vowel sequences. For example, if the word is "legal monsters", it will continue to "mortsnol segais". void inverterNvs(NO* elemento, NO*...
asked by 04.09.2017 / 18:34
1
answer

For what to use the "@" inside the printf of the solve function

#include <stdio.h> #include <stdlib.h> void solve(int QTD_DISCOS, int origem, int destino, int temp) { static int rank = 0; if (QTD_DISCOS > 0) { solve(QTD_DISCOS-1, origem, temp, destino); printf("%4d ) %c --> %...
asked by 01.06.2017 / 01:32
1
answer

Float rounding in C

I need to return a value float with 1 decimal place, however it is returning with the value rounded. I have the following code: float n1 = 4; float n2 = 9; float total = n2 / n1 ; printf("Media: %.1f ", total ); //aqui, o resultado é 2....
asked by 23.05.2014 / 20:21
2
answers

What is the suffix _t and when to use it?

I see in many codes some variables with the suffix _t . There are a lot of examples in the default C library as size_t , int32_t , mbstate_t . How useful, and when to use this suffix?     
asked by 29.09.2016 / 15:48
1
answer

Strange values in output when running newly compiled application

When I compile and run this code in Linux , it shows a strange result. I think it's rubbish from memory. What is happening to him to show this result, and how can I resolve it? Command lines to compile code gcc -c aluno.c gcc -c test.c gcc...
asked by 04.11.2016 / 22:54
1
answer

Doubt cast with pointer

while( ++idx <= fp_size) { byte current = buff[idx]; int integer = 0 ; short shortint = 0 ; if(idx < fp_size - 3) integer = *((int *))&buff[idx]; } What kind of cast is this *((int *)) ? var...
asked by 06.10.2015 / 00:00
2
answers

How can I print only the fractional portion of the number

Good evening, I would like to know how I can print the fractional part of the real number, that is, when I type 5.678, I would like to print in the second A (where the comment is), just the number 0.678, which I should use for the impression, I...
asked by 19.04.2015 / 01:05
1
answer

How to calculate months of a year from a decimal number?

#include <stdio.h> #include <stdlib.h> int main() { printf("\tPrograma para saber quanto demora a tornar-se génio!\n\n"); float tempo(int horas); float converter(float x); int num_horas; float dias,anos; print...
asked by 31.12.2015 / 19:20
1
answer

Does a char type always have size 1?

I've always known that char is the only type that has fixed size by specification. Its size is 1, no matter the architecture. But I came across sizeof('a') returning 4 rather than 1. Like this? Did I Learn Wrong?     
asked by 19.01.2017 / 11:18