Questions tagged as 'c'

2
answers

Factor function in C does not return result

What's wrong with my code? int fatorial (int n, int num, int fat) { if(num >= 0) { fat = 1; n = num; while(n > 0) { fat *= n; //FATORIAL = FATORIAL*N n--; }...
asked by 21.02.2017 / 14:08
1
answer

Typedef struct with C character vector is not working

I'm trying to create a constructive data type, but I'm having trouble with the strings. typedef struct { char nome[30]; int idade; } p; p x,y; x.nome = “ana”; x.idade = 20; y.nome = “caio”; y.idade...
asked by 02.02.2017 / 01:02
1
answer

Why is an expression with remainder and multiplication giving the wrong result?

Why is this code giving -2 instead of 7? #include <stdio.h> main() { printf("%i\n", 105 % 3*4 - 3*4 % (101 / 10)); system("pause"); }     
asked by 06.08.2016 / 20:22
3
answers

Program does not meet expected flow reading and printing entry

#include <stdio.h> #include <stdlib.h> int main() { int num1, num2, num3; printf("Digite o numero A e numero B para saber o resto da divisao resultante da divisao entre eles:\n"); printf("NumeroA: "); scanf("%...
asked by 05.11.2017 / 22:50
1
answer

Scanf is not stopping in repetition

I have a loop while that will only end when the value 0 (zero) is entered. I have a variable that will receive a command option. Within the loop I have a switch case where: 0) exits the program (returns to while and ends);...
asked by 25.01.2016 / 13:38
2
answers

Function gets on Linux

I'm trying to use the gets (C language) function, but it does not work. Am I using it the wrong way? The code looks like this: #include <stdio.h> typedef struct { int matricula; char nome[40]; int nota_1; int nota...
asked by 29.10.2014 / 22:33
1
answer

Error creating file in C

I'm trying to create a file in C, but it's not working. The operating system is Linux. #include <stdio.h> void main (FILE *file) { file = fopen("/home/Documentos/teste.odt", "w"); fprintf(file, "alo\n"); fclose(file); }  ...
asked by 18.11.2014 / 00:08
1
answer

Why can not I store the value '4294967295' in an integer of 4 bytes?

I would like to know why I can not store the value '4294967295' in a% byte of 4 bytes and the quoted value converted to binary gives exactly 4 bytes (or 32 bits)?     
asked by 03.05.2018 / 05:45
1
answer

In C, declare variables in the middle of a code block can cause the program to behave indefinitely?

I have read in several books that in C the variables must be declared at the beginning of a block of code. But what happens if I declare them in the middle? I was doing a program in c that shows text in a window created only using the X11 lib...
asked by 04.06.2018 / 12:21
2
answers

Why do some functions that work with C strings start with *?

In one of our classes we were taught that when a function receives as a parameter a vector, it is actually receiving the memory position in which it is allocated, so it is not necessary to return any value since what will be executed within the...
asked by 28.04.2017 / 16:45