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
votes1
answer184
viewsHow to get the program out of the loop
In the exercise I am doing, it is asked that when the number of repetitions is 0, finish the execution, but when I type 0 it does nothing and continues to read numbers. It reads a number K of…
-
0
votes0
answers123
viewsHow to install libcurl in Dev c++?
I tried to install here but the following code does not compile: #include <stdio.h> #include <curl/curl.h> int main( void ) { int a = 1, b, c; char post[1000]; CURL *curl; CURLcode res;…
-
0
votes1
answer198
viewsHow can I read a txt file in C, line by line?
I’m a beginner in C, I’m trying to read a txt file that has more than one line, but when I use fgets it only reads the first line, as I can read the entire file? what I’ve done so far void main() {…
-
0
votes1
answer80
viewsc what is the error of this code
#include <stdio.h> #include <locale.h> #include <stdlib.h> typedef struct { char marca[100]; //vetor de char, representa um string int…
-
0
votes1
answer34
viewsAllocate Attribute Memory in Structure
I need to allocate more memory of the note attribute of the Student structure: #include <stdio.h> #include <stdlib.h> struct Aluno { int matricula; int nota; }; void cadastraNotas(struct…
-
0
votes1
answer43
viewsProgram error of average in C, in result view
I’m a beginner in C programming, and in college we had to develop a program to make the average of 4 notes, and after typed, make the display, the program works without syntax error, but there’s…
-
0
votes1
answer83
viewsInvert string in C - String problem with even number of characters
Well, I have the code below that should reverse a string and show if it is a palindrome. However, when the word has an even number of characters the result is wrong. I think the error is in the…
-
0
votes0
answers20
viewsHow can I push Botton to turn on the display
I’m trying to make a display turn on but I need to push Botton first to start the count on the display.Can someone give a hint of how I should do? // configuração da pinos const int A = 2; const int…
-
0
votes0
answers11
viewsALLEGRO - Error in flip_display when starting draw_bitmap
all right? My code is giving error when I start it, the error occurs in al_flip_display(); and it always occurs when I try to start the al_draw_bitmap(rline, 120, 220, 0); If I remove draw_bitmap,…
-
0
votes0
answers41
views8 processes containing 3 parents and 2 of them raise 3 children in C
I’m having a hard time solving an exercise. I have to do a program that manages 3 parent lawsuits that in turn, two of them give rise to the creation of 3 child lawsuits. And in total, I have to…
-
0
votes0
answers44
viewsHow to compile C++ code with separate interface? (Arq.h , Arq.cpp and main.cpp)
I’m studying C++ for the Deitel book and I’m trying to compile a program where we have a gradebook file. h which is the interface, gradebook.cpp which is the implementation and main.cpp. Whenever I…
-
0
votes1
answer22
viewsHow to enter a discount value based on a year variation? Example: >2010=7% and <2010=12%
I developed a program where the user will inform the year of the vehicle and then the program will display on the screen the discount for the year. I still need to add a way to ask if he wants to…
-
0
votes2
answers64
viewsHow to insert Rand into C?
In portugol: Algoritmo "semnome" // Linguagem e Lógica de Programação // Lu e Gustavo // Descrição : Aqui você descreve o que o programa faz! (função) // Autor(a) : Nome do(a) aluno(a) // Data atual…
-
0
votes1
answer231
viewsMake Even and Odd List
I made a code where the user will insert an unlimited amount of numbers in a dynamic chained list until they type 0 and stop the insertion, showing at the end, all the numbers typed by the user. Now…
casked 4 years, 6 months ago Jardel Lima 11 -
0
votes1
answer72
viewsHow do I create a Dynamic Array in C?
I’m starting programming in C, after learning the basics in Python. At first I’m trying to write a simple program, which reads input arguments and prints them in reverse, for example, "hello world"…
casked 4 years, 6 months ago Pirategull 659 -
0
votes0
answers47
viewsStore tokens in dynamic C array
I am developing a console application that works as a shell (using processes to process commands sent via stdin). Entering the command to process with fgets(command, 1024, stdin) saves the whole…
-
0
votes0
answers59
views -
0
votes1
answer28
viewsProgram ignores the first scan of the loop
Basically I have this program int main(){ coordenada lista1_coordenadas[3]; coordenada lista2_coordenadas[3]; for (int i=0;i<3;i++){ printf("Leia a coordenada %d da primeira lista:\n", i+1);…
-
0
votes2
answers512
viewsChained List in C Language print inverse list
I need to create a list that gets n we and print these nodes normally and in reverse order, ie 1,2,3 to 3,2,1. I am new in programming area and would be very grateful for the help. I am using Dev…
-
0
votes2
answers59
views -
0
votes0
answers19
viewsProblem with reading string in C inside for()
I’m doing an algorithm for reading data for discount accounting, but the first data I have to read is the name. Everything worked perfectly, but I have to limit it to 10 "people" to fill in the data…
casked 4 years, 6 months ago Gustavo Lagares 11 -
0
votes1
answer148
viewsInput treatment with scanf() return
I’m trying to write an input treatment in my C code in the excerpt where the n values of an array and are read. If there is an error in reading (if the input is a char for example), assign 885444751…
-
0
votes1
answer44
viewsTransform and return a centered string s into a length width string
In this exercise I must pass to the function a string, a size and the character I want to include in the string, but I find problems when executing it, the string that should be centered ends up…
-
0
votes0
answers30
views"Dereferencing NULL Pointer" error in a chained list structure
My code deals with a simple endadeada list (then I will implement the pointer to turn double). But in the line strcpy_s(new_element->musica_name, musica_name); He keeps giving an…
-
0
votes2
answers31
viewsError exited, Segmentation fault when adding a second element to my list
This error only occurs when I add a second element to my chained list, I know the problem is in the Else of the inse_contact function but I can’t identify it. #include <stdio.h>…
-
0
votes1
answer30
viewsRead files in c
I have to perform a work that consists in the manipulation of values present in a.txt file, but I’m having difficulties with reading these values. The.txt file is arranged as follows: n Nome1 Wage 1…
-
0
votes0
answers50
viewsHow do I compare the address of a vector position N with an address the user enters?
I’m having trouble solving this question. Could someone help me ? Follow the body of the question: 6 - Make a program that simulates 'virtually' the memory of a computer: the user starts by…
-
0
votes1
answer43
viewsDoubt about while loop on C?
I need to know why 0 has to be typed twice in order for the program to stop traversing the loop. And the same thing happens when I use the do-while. #include <stdio.h> #include…
-
0
votes0
answers22
viewsC printthe computer directory, when function receives tithe
I am doing a function in C, which given a fractional part "frac" of a number in base 10, and another numerical base, returns the same fractional part in the desired base. To do this, I allocate a…
casked 4 years, 5 months ago Gabriel Arruda 45 -
0
votes1
answer293
viewsSave data from a txt file to an entire struct or manipulate struct. C
I have a txt file that follows the template below. I want to save the balance as int, but with fgets I can’t get it. I’m wanting to save as int, because after the data is taken the program sorts…
-
0
votes0
answers66
viewsError: My matrix does not print the last line and sometimes only prints half
I’ve done a lot of different things... for(i=0; i<=2; i++){ for(j=0; j<=3; j++){ O[i][j] = (3*M[i][j]) - (5*N[i][j]); printf(" %3d ",O[i][j]); } printf("\n"); } However the matrix does not…
-
0
votes1
answer36
viewsDelete queue element and release memory for this function?
I’m starting to understand pointers better and I’m implementing a queue, and it follows the function: FILA *removeNodeFIFO(FILA **raiz) { FILA *aux = *raiz; if (aux == NULL) { return NULL; } else {…
-
0
votes1
answer46
viewsMatrix in C language, error zsh: abort
I’m trying to create a matrix to read the names of 5 students. #include <stdio.h> #include <stdlib.h> int main(void){ //Programa para calcular a média das notas de 5 alunos, sendo que…
-
0
votes0
answers33
viewsHow I take the space from the char when I type more than one word does not appear / on type the phrase
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <locale.h> #include <ctype.h> #define MAX…
-
0
votes0
answers33
viewsWhat is the best way to save multiple data types of a struct {} in a text file?
I need to create a program that registers a user and stores their respective data in a text file. It happens to be various data (Name, CPF, Phone, Address, email, etc.). Then I created a struct full…
-
0
votes1
answer95
viewsWith reading numbers without pressing "enter" in C language?
I’m writing a program, and I have a little problem. When choosing one of the options you must press "enter" to proceed, however when pressing "enter" it already enters the next screen, thus skipping…
casked 4 years, 5 months ago heisenbeck 9 -
0
votes0
answers164
viewsExercise in C - Semaforos
Hello, I’m doing an exercise in C but I found some difficulties, the goal is to use the lib #include <pthread. h> when using the code of this template #include <stdio.h> #include…
-
0
votes1
answer40
viewsHow to pass string to an insert function
#include<stdio.h> #include<stdlib.h> #include<string.h> struct lista{ char nome[20]; int idade; struct lista* prox; }; typedef struct lista Lista; Lista* lst_cria(){ return NULL; }…
-
0
votes0
answers92
viewsfread e fseek in c
Write a program using fwrite and fread that asks the user the type of shopping list he wants to create: Bakery or Barbecue. The program must save the items in a text file until the user type 0…
-
0
votes1
answer35
viewsRandomly generate values from a repeatless vector in C
I have the following scenario, which is a vector of questions that should be asked to the user randomly. The problem is that after I enter the first input value the array is iterated right after…
-
0
votes1
answer49
viewsCan someone help me with this exercise?
EXERCISE: Write a function that returns the number of the team that is in the lead. Leadership is determined by the team that has the most points won. If one or more teams have the same number of…
-
0
votes0
answers59
viewsProgram that Tells how many repeated numbers you have in the column and row of an array
To simplify, I have to make this ex: **Write a program that reads two sequences of ten integer numbers and prints on screen how many of these numbers are present in the two sequences and how many…
-
0
votes0
answers23
viewsWrite to file . txt with C
Hi guys!! Here I am again having problems with files... I made a program to register patients with covid. The data of these patients should be recorded in a txt file. The problem is this: the data…
casked 4 years, 4 months ago Lady Pavlichenko 11 -
0
votes1
answer102
viewsDisplay values that are equal by comparing the 2 matrices
For the first time I found myself lost in the exercises I think I didn’t get the logic well, but I’m studying to understand. I will show my source code in full is small and the question. I would…
casked 4 years, 4 months ago Leandro Batista 3 -
0
votes1
answer35
viewsError accessing a struct
I created a function to read how many hours the employee worked in the week, however, I have problems effectively saving in the memory of struct. Calling the function:…
-
0
votes0
answers64
viewsProblem with overflow in c, my variable bursts
This code is used to add two binary numbers and write the result but in the output this appears: warning: overflow in conversion from 'long long int' to 'long int' changes value from '10100101010'…
casked 4 years, 4 months ago Lucas linard 11 -
0
votes1
answer60
viewsHow do I make the program identify if the split denominator is zero using switch-case and display an invalidity message in the operation?
I have this exercise to do and everything is going well, but I do not know how to make the program analyze if the denominator is zero and display the message, can help me? My code: #include…
-
0
votes0
answers33
viewsWhy fgetc(stdin) does not recognize the end of a file?
For some reason the fgetc(stdin) is not recognizing the end of a file line and it is in the while infinitely. fscanf(arqIN, "%*s %d", &qntPacientes); // Aqui é só pra pegar a informação da…
-
0
votes0
answers24
viewsData is not recorded in the files in c
In this exercise I have to create a register of cars in two files. In one file I have to register all the cars, in the other I have to register only the sold ones, but only the files are created but…
-
0
votes0
answers53
viewsC language problem with queues and write to text file
I have a college job to do, but I have a lot of difficulty in language C the job is to create the following functions int InserirAviaoFila(char *voo); int MostrarFila(); int AutorizarDecolagem();…