Questions tagged as 'c'

1
answer

Use of typedef for pointer

If I have already set a pointer to my structure because I can not allocate it. #include <stdio.h> #include <stdlib.h> struct ponto { int a, b; }; typedef struct ponto *Ponteiro; // define um ponteiro para estrutura ponto typed...
asked by 10.09.2018 / 23:06
2
answers

How to pass an array as a reference to a function?

I'm trying to pass an array as a parameter to a function as a reference, and in this function I do operations on that array but I'm not getting it. I do not want you to use define or const int for the array dimension values because...
asked by 30.09.2018 / 16:16
2
answers

What is it for {} inside the main

I came across a C situation I do not know and had never seen anyone use before. Within the main() method there are several keys, I believe to isolate the code however there is a same variable that in each block of code receives a value an...
asked by 21.08.2018 / 22:06
4
answers

Buffer Cleanup after getchar

Good morning, I wanted to know how I can optimize buffer cleaning when using the getchar () function, as an example follow the following codes: I get the following code from the correct output using the "scanf spacing" technique as shown:...
asked by 11.12.2014 / 18:03
1
answer

How can I apply HTML / CSS to a pure C program?

The programming club I'm attending has completed a program that functions as a stock controller and shows things that are available and things borrowed. It was done in pure C, so the display is quite archaic, It looks like this: | Control...
asked by 16.07.2017 / 00:10
2
answers

How to write a recursive function?

I was given the task of making this function recursive, but I have no idea how to do it. int existe (int x){ FILE *arq; int y; char buf[MAX]; arq = fopen ("cliente.txt","r"); fgets (buf,MAX,arq); while (!feof(arq)){...
asked by 29.11.2015 / 21:13
2
answers

What is the purpose of the sizeof command?

What is the purpose of the sizeof command in C language ?  I know I can use it to allocate memory and dynamically create vectors as follows vetInt = malloc(sizeof(int) * tamanho); . Otherwise this command has another function?   ...
asked by 22.08.2015 / 23:12
4
answers

Obtaining Rest of a Floating Point

I have a question about this. Let's say I have a floating point, with a value of 1.13 (Minutes.Seconds) How do I get the rest (13) of the floating point? Minutes. Seconds (Rest)    1 . 13 How do I get the floating point 13?     
asked by 07.02.2016 / 23:00
2
answers

Concatenate text with variable char in printf

I need to concatenate the person's name (variable) with a text. Following logic, it would look like this #include <stdio.h> int main (void){ char nome[6]; printf("Ola! Insira seu nome, por fovor: \n"); scanf("%c", &nome)...
asked by 10.04.2016 / 02:03
1
answer

Why is the size of a struct not the sum of the sizes of its variables?

For example, the following code: #include <stdio.h> struct exemplo{ char letra; int numero; float flutuante; }; int main() { printf("Tamanho do char: %u\n", sizeof(char)); printf("Tamanho do int: %u\n", sizeof(int))...
asked by 24.04.2016 / 21:24