Questions tagged as 'c'

1
answer

Why have so many parentheses in macro?

Seeing this intrigues you because you need those parentheses that seem unnecessary. What is their functionality? #define SUB(x, y) ((x) * (y))     
asked by 23.03.2017 / 11:37
1
answer

How to use the toupper () function in char in C?

I'm creating a variable: char nome[20]; After this, I'm asking the user to enter a name: printf("Digite um nome : "); scanf("%20s",&nome); And I'm checking to see if the name is correct: if(strcmp(nome,"Maria") == 0){ pri...
asked by 28.03.2017 / 20:06
2
answers

How to solve accentuation problems when using the setlocale function?

I'm trying to set the program language to Portuguese, using setlocale(LC_ALL,"Portuguese") , however, much of the program was done in Ubuntu. When the other programmer sent me the files and when I am going to compile using mingw32-make to...
asked by 08.02.2016 / 20:45
1
answer

How does printf work?

How does the code behind the function printf() of C work? I know what this function does, I want to know how it works.     
asked by 04.08.2015 / 21:51
1
answer

How to make a wrong user entry not bug the program?

Example, I declare the menu option as int , hence the little bug goes there and types a letter or a special character and this will make the program bugar. The question is: can you solve this? Example: int opc; printf("Digite uma opçã...
asked by 13.06.2015 / 15:28
2
answers

How to implement a queue using two stacks

Hello, I need to implement a queue using two stacks, that is, I need to insert an integer in stack 1, and when I remove an element all the items in stack 1 must be transferred to stack 2, then make it look like with a queue. Items in stack 1 c...
asked by 08.09.2018 / 23:01
2
answers

How to write a string in a stream using physical files?

When you insert characters from a string into a text file into C, white space is ignored. How do I make long sentences within a string separate from words? Follow the code: #include <stdio.h> #include <stdlib.h> #include...
asked by 17.02.2014 / 21:48
1
answer

Problems with dynamic allocation

In a given exercise, make a record of a struct possibly declared as follows below. typedef struct Locatarios { char nomeLocatario[MAX_NOME]; int codigoLoc; float valorAluguel; } Locatarios; Dynamic allocation is required...
asked by 14.11.2014 / 21:44
2
answers

Determine specific size for console in C

Is it possible to set a specific size for the codeblock console (In C language) to open when I run the program? I need it to open in a certain size because I will not use the whole screen. I saw that there is a way to do it in the windo...
asked by 19.11.2015 / 21:50
2
answers

What is the difference between the syntax ptr = (int *) malloc (sizeof (int)) and ptr = malloc (sizeof (int))?

I have a doubt about dynamic allocation in C. At the moment of allocating the memory I already saw these two types of syntax: ptr = (int*) malloc (sizeof(int)); ptr = malloc (sizeof(int)); But I do not know the difference in use between th...
asked by 20.03.2018 / 21:11