Questions tagged as 'c'

1
answer

How to increment an enum in C?

Objectively how do I increment ++ or += 1 one of the variables of enum (the increment will be in a loop / switch ): enum {um = 0, dois = 0 ... seis = 0}; I read this question and I did not quite understand. Is...
asked by 22.03.2017 / 05:05
1
answer

Bitwise operation

In my first semester of college I made an algorithm to avoid wasting memory, just for testing. Now I'm passing this code to C: Here is the whole code: // 8 bits // Aguenta até 4 slots (0 - 3) // Valor inteiro máximo suportado: 255 void...
asked by 16.03.2017 / 17:49
2
answers

Function calculates to some extent and for

I have a double variable making an account but it reaches a limit [in my case 1.367879] and it does not increase any more. The code is running normally, the problem is the result that is no more than 1.367879 #include <stdio.h>...
asked by 31.05.2016 / 02:30
1
answer

Total number of elements in a stack

I want to know how to return the total number of elements in a stack on the screen. For example: I have a vector stack of size 10 and stacked 6 elements in it, it will have to return the total of 6 elements. I have this code here, but it is n...
asked by 30.03.2017 / 15:20
2
answers

Why use extern?

According to what I researched , the reserved word extern in C is used to inform that the declared variable is somewhere else in the program. A variable extern is useful for saving memory, because extern variables, although...
asked by 05.04.2017 / 10:52
2
answers

determining a string inside a switch in C

I have doubts on how to define a string inside a switch in C, without having to do a table of constants for this. The variable name_lanche is of type char, but this is the number of characters defined, so I am using it as a string. I ne...
asked by 07.09.2016 / 22:56
1
answer

Convert hexadecimal string to output readable in C

I would like to save a text in hexadecimal, and calling a function, the hexadecimal string is converted to a readable char string ie decoding hexadecimal, such as 0x6f0x69 to oi . I've tried the following: #include <stdlib.h...
asked by 04.09.2016 / 22:00
1
answer

Highest value of a vector, with recursion

I'm studying about recursion and vectors, but I can not figure out how this method works, which returns the highest value using recursion. int maximoR (int n, int v[]) { int x; if (n == 1) x = v[0]; else { x = maximoR (n-1, v);...
asked by 05.09.2016 / 16:55
1
answer

How to read text files and put the words in a vector?

I need to make a code that reads a text file (txt) and save only the words in the positions of a vetor , below my code follows: int main(int argc, char** argv) { FILE *file; file = fopen("arquivo.txt", "r"); char x[100];...
asked by 16.01.2016 / 16:27
2
answers

Error with sem_init () function in Linux

I'm trying to solve a problem with semáforos , but when I try to use the sem_init() function I get an error saying that there is undefined reference, Can you tell me why? I have the semáforos library included. Code (C)...
asked by 27.01.2016 / 23:54