Questions tagged as 'c'

2
answers

How to get the length of a char array?

How do I get the size of a set of char ( char** )? The way I'm trying is always returning me the value 4. const char* opcSalgados[] = { "Pastel", "Mini pizza", "Coxinha", "Pao de queijo", "Pao de frango com queijo", "Pao de carne"...
asked by 14.12.2017 / 16:45
1
answer

How to access a pointer inside a pointer structure

I know that to access a normal variable inside a pointer structure I can use this syntax: struct teste { int valor; int *aponta; }; struct teste testando, *testado; testado = &testando; testado -> valor = 10; However, how...
asked by 28.02.2018 / 04:07
1
answer

How does the frame-pointer work?

In the official GCC documentation there is a option that allows you to remove the frame-pointer when not needed. What does the frame-pointer do? How to remove this pointer can improve performance?
asked by 16.02.2017 / 11:49
1
answer

Is there a way to call a C function in C #?

Let's say I have a library with a C function, which was compiled using gcc, is there any way to call this function in C #, if so what would its performance compare to the same function created in C #?     
asked by 25.09.2016 / 18:22
3
answers

Incorrect counting in electronic ballot program

I created an urn with the C language. The code is apparently correct, but the vote count always hits zero. The code was developed in the code: blocks in Linux, so in order for it to work on windows, the lines of the sleep and system ("clear") co...
asked by 27.09.2016 / 18:12
1
answer

How do I know address of each position of the vector in C?

I'm having trouble knowing the vector address and address of each vector position. #include <stdio.h> int main(){ int vec[]={52,13,12,14}; printf("Endereço de vetor %d",&vec); printf("vec[0]%d,vec[1]%d,vec[2]%d,vec[3]%d\n", &v...
asked by 26.09.2016 / 23:16
2
answers

Overloading C ++ operators, is the auxiliary variable necessary in this case?

I'm studying through the book Introduction to Object Oriented Programming with C ++ (Antonio Mendes da Silva Filho), and I implemented an example of it as follows: #include <iostream> using namespace std; class Contador{ public:...
asked by 03.01.2017 / 16:17
1
answer

Different values between variable without value and variable with null value?

#include<stdio.h> int main ( void ){ int die1[7]; int die2[7]; int sortedDie, i; srand(time(NULL)); printf("Rolling die 1\n"); for( i = 0; i < 6; i++){ die1[i] = 1 + rand()%6; } printf("Rolling die 2\n"); for( i = 0; i <...
asked by 08.01.2017 / 04:48
1
answer

How to decide the type of a function?

In many C codes I see on the internet, I only see functions of type void and int and can declare functions of other types? For example struct and float . I made a simple test with the types char and float...
asked by 23.06.2016 / 00:41
1
answer

Why does a string assignment in C not work?

I'm having trouble assigning a value to a variable of type char of a struct I'm doing the following #include <stdio.h> typedef struct Animal{ char nome[5]; // indiquei que a variavel nome tem 5 caractes int idade;...
asked by 23.06.2016 / 04:08