Questions tagged as 'c'

2
answers

Why subtract -48 from a char it becomes whole

I saw in another forum that the guy subtracted -48 from a char and the char became an integer, did that happen? #include<stdio.h> int main(){ char num='3'; printf("%d",num-48); return 0; }     
asked by 05.05.2018 / 15:34
3
answers

Why is it not possible to assign a string vector after it has been declared, a character?

char vetor[10]; vetor = 10 /*ERROR*/ Why is this happening? Is it about vectors being composed?     
asked by 07.02.2018 / 15:01
3
answers

Doubt with float

#include<stdio.h> int main ( void ){ float y = 12.0809; printf("The number %.2f is a float\n"); return 0; } I know that %.2f is used to consider only two decimal places, but I'd like to know what an integer serves before the peri...
asked by 07.01.2017 / 03:37
3
answers

Comparing string contents in C to find palindrome

I need to check if a string A, for example, is equal to string B to determine if the entered word is a palindrome, string B is the inverse of A, I can not determine if the contents are the same. For example, I enter with the word "macaw", t...
asked by 26.03.2017 / 23:48
2
answers

Decimal to binary conversion in C language

The code below, from the original ( link ) "prints" a decimal number between 0 and 255 in binary. #include <stdio.h> #include <stdlib.h> int main() { int n; // Número de entrada int r; // Resultado do deslocamento int i; // C...
asked by 28.06.2017 / 05:03
3
answers

Allocate memory in C for structure vector

What is the right way to allocate memory for an array vector? struct CARRO{ int id; char fabricante[MAX]; char modelo[MAX]; int ano; char cor[MAX]; int preco; }; int main(){ int qtd, i; scanf("%d", &qtd);...
asked by 27.06.2017 / 04:25
2
answers

Maximum size of a character vector

Is there any maximum quantity, that a variable of type char supports character? For example, could I use char texto[1000]; ? #include <stdio.h> #include <stdlib.h> #include <locale.h> int main(){ setloca...
asked by 22.11.2018 / 19:06
3
answers

How to pass a struct vector by reference parameter?

My question is, what is the error of this passage? It looks like the (*dadosCliente+i) pass is incorrect, does anyone know why? struct cliente{ char nome[50]; char endereco[50]; } void addCliente(struct cliente *dadosCliente, i...
asked by 03.02.2014 / 17:48
2
answers

Problem with pointer and array

I wanted to print the corresponding places and values from an array using a pointer, but when I ask the pointer to add the location of the vector with 8 (which corresponds to the 8 bits of an integer) program sums up values that I do not even kn...
asked by 06.10.2017 / 05:05
2
answers

Copy string from given character

I'm developing a C program, which will work with 02 files .txt The first file is a report, which comes out directly from the system, and there are information such as item code, location and quantity in stock, this information is on th...
asked by 02.01.2017 / 23:35