Most voted "c" questions
C is a general-purpose computer programming language used for operating systems, games, and other high-performance jobs and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the UNIX operating system.
Learn more…4,811 questions
Sort by count of
-
0
votes0
answers26
viewsFunction that copies vector to another, already passing the destination address as parameter
I want to make a function that copies a vector from double to another vector, allocating the new vector in the function that copies it. That is the function: void copiarvet(double *vet_origem,…
casked 5 years, 4 months ago Gustavo Oliveira 61 -
0
votes0
answers537
viewsData compression in C
I need to implement a C program that makes the creation of compressed files from text files (for example, C program sources, among others). This compression will be performed using the Run Length…
-
0
votes0
answers48
viewsRand() function in C
Hello, I saw this line in a code on the net and I’m having a hard time figuring out what it does exactly. (Rand() %9 == 4) ? 4 : 2; I know it gives the value 4 or 2 But what is "%9 == 4", the " and…
-
0
votes1
answer54
viewsDimension of a vector passed by reference language C
I would like to know how I discover the amount of positions that have a vector that has been passed by reference to the function, using the language C. Example (Function prototype): int Soma (int…
-
0
votes1
answer235
viewsArduino serial communication
I’m trying to figure out a certain exercise my teacher gave me in class. Basically the exercise is: With two arduinos prepared to make the serial communication between TX and RX, this must transmit…
-
0
votes2
answers124
viewsLoop problem when using Do-While (C language)
I have a problem with this function. When I enter a non-integer character, it is in an eternal loop. int menu() { int escolha,acao; do { printf("\n============== MENU ==============\n\n");…
casked 5 years, 3 months ago Manrique Pereira 1 -
0
votes2
answers2255
viewsHow to get the rest of a float number in C?
This is the question of the URI I thought of this idea more when I’m going to take the rest of float numbers I can’t... #include <stdio.h> int main(int dinheiro) { int res, res2; Here I have…
-
0
votes0
answers135
viewsI cannot compile c++ or c code in any ide
For a while I’ve only been able to compile c or c++ code in my cmd. And I can’t compile in any ide. Whenever I try to compile the error appears:…
-
0
votes2
answers354
viewsTwo strings starting from one, in C
Hello, I need a software that reads a full name, composed of a simple name and a surname, separated by "_" and prints them separately. The code should use the following main function: #include…
-
0
votes1
answer4365
viewsInstruction similar to system("cls") in C
The program I am doing works as follows: Whenever an incorrect value is typed, I want the program to warn that the value is incorrect, and soon after clear only the error message so that the user…
-
0
votes1
answer242
viewsFilter information in an XML using C
I need to extract relevant information from a XML which has this structure: <ARTIGO-PUBLICADO SEQUENCIA-PRODUCAO="2"> <DADOS-BASICOS-DO-ARTIGO IDIOMA="Inglês" DOI="" FLAG-RELEVANCIA="NAO"…
-
0
votes1
answer176
viewsBinary tree of search
#include <stdio.h> #include <stdlib.h> #include <string.h> struct arvore { int key; struct arvore * right, *left; }; typedef struct arvore Arvore; Arvore * alocar(int key) { Arvore…
-
0
votes1
answer59
viewsCounter with float number
I’m new to C programming. My problem is that I’m not able to add float numbers with an i counter, which would be integer, which is the best solution? #include <stdio.h>…
-
0
votes0
answers101
viewsConvert integer to string in C
I have a problem with converting an integer to string in the scope of a function where the conversion return is given as null and I don’t know why. #include <stdio.h> char *getTexto(int num) {…
-
0
votes1
answer164
viewsProblem with scanf
Hello, I trying to make a customer registration in C using struct and I came across the following problem: When was going to read the user’s DDD with scanf it did not save, nor even print the value,…
casked 7 years, 4 months ago System_4n4n 57 -
0
votes1
answer9962
viewsConverting int to string
I made a program that simulates a login and when converting the password that is int to string using sprintf it from segimentation falt, I tried to use itoa but it from the definition error #include…
-
0
votes0
answers23
viewsValue of n in Malba Tahan Chess algorithm
I am in doubt about the value of n in the code, in the "for" below 1 is assigned to the value of n, so it would not be for the first iteration the value of n to be 2? #include <stdio.h> int…
-
0
votes1
answer1018
viewsHow to remove a node in a binary search tree with these specifics?
I have the following binary tree : Defined by the following data manure : typedef struct Node{ int data; struct Node * left; struct Node * right; } node; typedef struct Node * root; And I have the…
-
0
votes1
answer668
viewsI need help creating the Makefile file
# Baseando-se no link: https://www.embarcados.com.br/introducao-ao-makefile/ all: bancoBPE bancoBPE: main.o gcc -o bancoBPE main.o -Wall -Wextra -Werror -Wpedantic # Não sei direito como compilar…
-
0
votes1
answer103
viewsInclude spaces when reading C strings
Good staff I have a C job to do, where I have to read information from a txt. Each string follows the following format: 12345António Manuel Silva Mendes Frankfurt Varsovia 1 It always has a…
-
0
votes3
answers503
viewsSum of geometric progression terms
I need to do a show that fits a1, q , n (number of geometric terms) to calculate the terms and then calculate the sum of those terms. I was able to calculate the terms, but I have no idea how to…
-
0
votes1
answer321
viewscommand prompt instantly closing
I am programming in C and using Code Runner to run the code, but whenever I click Run, the command prompt opens and closes very quickly. The problem is with the command prompt closing alone, because…
-
0
votes0
answers19
viewsError with multiple IF conditions
The if only proceeds if it’s’m' the person’s sex, if it’s the others with || that I put will not, can anyone take away this doubt? char sexo; float altura, pesoideal; printf("Qual o sexo da pessoa?…
-
0
votes2
answers202
viewsForce while loop output on C switch
Guys, I made a menu in C language, but I need that when the user type option 4, it comes out of the repetition loop of/while, someone can help me. Thanks again to all for participating. int opcao;…
-
0
votes0
answers582
viewsC - when I use the site. h scanf does not work well
I’m creating a database. I used the locale.h and setlocale(LC_ALL, "Portuguese") for accents and cediles to appear on the windows command line. Because of this when I make one scanf of an…
-
0
votes0
answers18
viewsDifference in passing of data type by reference
Hello, I’m having doubts about how to pass determined by reference. Follow the code below: #include <stdio.h> #include <string.h> mostra_frase(char *frase){ printf("\nFrase digitada…
-
0
votes2
answers59
viewsdifficulty sqrt()
I need to calculate the area of a rectangle triangle but I cannot identify the error. #include<stdio.h> #include<math.h> int main() { //declaracao de variaveis int a, b, c; int s; int…
-
0
votes2
answers63
viewsInput is not making sense
void cadastroturma () { char turma[30],caminho[100]; printf ("Diga o nome da turma a ser cadastrado:\n"); scanf ("%[^\n]", &turma);//Já tentei com gets e fgets getchar();//Já tentei sem esse…
-
0
votes2
answers31
viewsError in condition return
even after typing a negative value, Else returns nothing ;( #include <stdio.h> int main (void) { //variaveis int dia, mes, ano; //inicio printf("\ndigite o dia: "); scanf("%d", &dia);…
-
0
votes0
answers36
viewsProblem in removing nodes on a list
Good night, I’m doing a show that’s sort of a "Candy Crush" on SDL. And I needed your help to help me remove the balls from the game, which in this case are the nodes on the list. The program is…
-
0
votes1
answer172
viewsCreate a vector with srand without repeating numbers in C
I am creating a vector with random numbers from 1 to 60 using the Rand function. This vector cannot contain repeated numbers. For example, if srand’s return was number 3, and there is already a…
-
0
votes2
answers610
viewsArray by function in C
Good morning! I’m having trouble passing a vector to void function for the sorting to be done and returned, as well, problem to pass to another void function whose purpose is to display the already…
-
0
votes1
answer48
viewsI have dynamically stored memory of a vector in C, does not return the allocated size, why?
This code is an example of another code with the same problem. I dynamically stored the memory, but when I’m printing the vector size with the len, strangely prints 1 and not 10 as expected. The…
-
0
votes2
answers88
viewsHow can I split a string by semicolon and take the value of each position after the while?
How can I make one split of a string per semicolon and take the value of each position after the while ? Example: result[0] //casa result[1] //carro My code: char str[] ="test;car;bar;mouse"; char *…
-
0
votes1
answer73
viewsIn C language working with strings would it be better to spend processing or memory?
In general in programming it is better to spend resources on processing (calculations) or memory (creating variables)? Contextualizing: I am developing a solution for a program that uses struct and…
-
0
votes1
answer126
viewsCapicua’s algorithm is not printed as it should
Program to find all Capicua numbers (a number that is read in the same way backwards and forwards) between 10 and 500. I tried to do this but the figures are not being printed. #include…
-
0
votes0
answers62
viewsProblem reading a C string
I would like to know why my programme does not accept reading the name of the second and third students at all. I’ve already used the buffer clean command, which is fflush(stdin) and he hasn’t done…
casked 4 years, 11 months ago Matheus Santos 41 -
0
votes1
answer48
viewsCode does not display result
My code receives as input the value of n, i and j and calculates the n first multiples of i and j. I’ve gone through my loop loop and I can’t find anything wrong, but the compiler just stands still…
-
0
votes1
answer35
viewsFactorial calculation without finishing the program
How would I make this algorithm not to terminate the program and allow me to write other numbers to calculate the factorial? I’ve tried putting one while, or do while, but in no way works, because…
-
0
votes1
answer1153
viewsElement removal at the beginning of C chained list
In this C program, I’m trying to create a function that removes the first element of a chained dynamic list... #include <stdio.h> #include <stdlib.h> struct no { int dado; struct no…
-
0
votes1
answer21
viewsHow to add "" to an input
How do I add "" to an input? I tried to do it in many ways but the one I got closest to was this, but it does not return a word, it returns "(null)" int main(void) { char p; char x = 34;…
casked 4 years, 11 months ago user185128 11 -
0
votes1
answer697
viewsPassing matrix to function by reference
Good morning everyone, I wish in my code to leave the Main(); only with calling functions, all work is divided into small functions in the document. I want to write a matrix[3][3] in a function and…
-
0
votes1
answer51
viewsError with C array - Norwegian
I’m having error signing an array: Menu m = Menu(); m.Options[4] = {"teste1","teste2","teste3","teste4"};//Erro aqui m.Show(); Menu Class: class Menu { public: String Options[]; int index = 0; int…
-
0
votes2
answers179
viewsIs there realloc() in C++?
The realloc() is unique to C? Would it have any function that would be equal in C++?
-
0
votes0
answers18
viewsDoubt using C Pointers
I wonder if there is any difference using %d instead of %p to return the pointers address. Using the %d operator is good programming practice? int a, *aPtr; aPtr = &a; printf("Digite o valor de…
casked 4 years, 10 months ago Matheus Santos 41 -
0
votes1
answer50
viewsArray size set by variable
I checked and I see no mistakes. void exibe (int * , int); int main(){ int n; int m[n], i; printf("Digite o numero de elementos do array : "); scanf("%d",&n); for (i = 0; i < n; i++){…
-
0
votes2
answers758
viewsDoubt in c (chained and vector lists)
How can I create an array where each position is a pointer to a chained list ? For example: typedef struct info Info struct info { int num; Info* prox; }; And then I want to create a vector, and do…
casked 4 years, 10 months ago GratefullyDead 373 -
0
votes1
answer60
viewsWhen a C program is compiled, does it include all the dependencies necessary for its operation?
When I compile a program in C, will all dependencies be compiled together? If not, it is possible to compile them? For example, if I include a certain library in my program, when I compile it, I…
-
0
votes0
answers186
viewsReturn string array in c
I am trying to return an array of strings to use later in main. Here is my function: char **separar_palavras2() { setlocale(LC_ALL, "Portuguese"); FILE *arquivo; arquivo = fopen(ftexto, "r"); int i…
-
0
votes1
answer79
viewsError when comparing matrices
The question asks for a comparison of matrices,I tried to compare them, but the answer if they are equal appears several times and I do not know how to solve this problem, is what is causing the 10%…
casked 7 years, 3 months ago rafael marques 939