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
answer75
viewsDifficulty in ordering
I’m doing a program that sorts the words, only if they’re the same size you can’t change places, I’m stuck in that part, the code I already have #include <stdio.h> #include <string.h>…
-
0
votes0
answers30
viewsError in the algorithm ofBoyer-Moore
I’m studying how to count how many times one string appears on the other, and I found this site Website link, in it has the algorithm deBoyer-Moore, which finds number of occurrences of a in b, but…
casked 6 years, 7 months ago rafael marques 939 -
0
votes0
answers714
viewsLike "draw" a binary tree?
I walk with a problem trying to create an algorithm to "draw" a binary tree as below: But I’m having trouble implementing. I’ll show my code below: #include <stdio.h> #include <stdlib.h>…
-
0
votes0
answers103
viewsString vector condition error in C
I’m having a hard time with a specific exercise: #include <stdio.h> #include <stdlib.h> #include <locale.h> #include <windows.h> #include <ctype.h> #include…
-
0
votes1
answer31
viewsHow to read a file in C but not to count with the header in the counter?
FILING CABINET The first line is the header I want to disregard. So that the counter "num" does not start counting from the HEADER Company About Funcao Name Empresaa Bedecs Anna Proprietario…
-
0
votes0
answers66
viewsWhen printing string, meaningless characters are shown
I need to do a program that calculates the average salary of a company, asking the user for the amount of employees, the name and salary of each employee and returning the average, the name of the…
-
0
votes0
answers305
viewsShell Sort Ordering Algorithm Comparisons and Exchanges Count
How can I count the number of Shell Sort comparisons and exchanges? Where to use counters correctly? void ShellSort(int vetor[], int n) { int i , j , val, comp=0, swap=0; int gap = 1; while(gap <…
-
0
votes1
answer704
views(C) Make an algorithm that reads a string and removes vowels and whitespace
The code is copying ALL characters from one string to the other and ignoring the copy condition. I know there is an easier way to remove spaces and vowels, which is to bring the next character to…
-
0
votes0
answers126
views"Indefinite reference to`itoa' " message when trying to use itoia function
I found on some websites people talked about using the itoa function to convert an integer number into a string containing the number in binary format. Code example that should do this:…
-
0
votes1
answer240
views'function name_name': identifier not found
void inserePoli1(poli **topo1, int val, int expo) { polinomio1 *novo; char cmd; novo = new poli; novo->valor = val; novo->expoente = expo; if (*topo1 == NULL) { novo->prox = NULL; *topo1 =…
-
0
votes1
answer89
viewsWhy don’t you get in the loop?
I’m storing student names and grades and trying to display name, grades and media. The problem is that the program is skipping the loop of notes and is only taking the name. #include <stdio.h>…
-
0
votes0
answers103
viewsDoubt program that copies from one file to another in C with functions
I have to do a C job that copies one file to another at release time (on linux using argc and argv). I’m not used to file manipulation, but here’s the code and it’s not working, what can I do to…
-
0
votes1
answer493
viewsReverse Dynamic Stack
Could someone help me with this pile? The goal is to create a function that reverses the values of the stack, I tried to do this using the Invert() function of the code below, but it is not working,…
-
0
votes2
answers401
viewsFactorial function does not return
I need to use function in C but is not returning the factorial. Problem:"Given an integer n, calculate its factorial n!. The factorial of a number is given by the equation: n! = n(n1)(n2) : : : 1.…
-
0
votes1
answer38
viewsThe queue code has an error in the search. How can I fix it?
I use the search twice in my code and it is a binary search in order to respect the criteria imposed in the header of this exercise. But the doubt lies in the binary search module because the…
-
0
votes1
answer177
viewsUnable to locate -lGL
I’m running the default Codeblocks code for Opengl on Ubuntu: /* * GLUT Shapes Demo * * Written by Nigel Stewart November 2003 * * This program is test harness for the sphere, cone * and torus…
-
0
votes2
answers208
viewsIs it always good to de-locate the memory before a "sudden" output of the program with the Exit function call?
When I was beginning to learn pointers and dynamic memory allocation in C, I was told that all memory allocated in the program is out of focus when it is finished. Ex: #include <stdlib.h> int…
-
0
votes1
answer406
viewsRemoving specific element from a double-linked list
I created a function to remove a specific element from a list. However, the code only works right when it comes to the first element. The logic is that when the element arrived in which it relates…
casked 6 years, 6 months ago user103375 -
0
votes1
answer117
viewsprime numbers between a sequence
The problem is this, I have to receive an integer value and calculate the factorial of this number (until then quiet), and take and print on the screen the prime numbers that exist between one and…
-
0
votes1
answer69
viewsHow to allocate space for each structure of an array as the user wishes?
Guys, how do I allocate one structure whenever the user wants to allocate another one? How do I make this increment? I’m putting a code here just so you can understand my problem. #include…
casked 6 years, 6 months ago Lucas Correia 53 -
0
votes1
answer133
viewsHow to declare null values in C
My problem is the next one I’m creating loop while which cannot receive values less than or equal to zero, and would also declare that it cannot receive empty values for the program force the user…
-
0
votes1
answer67
viewsSlow execution of a repeat problem for c
I made this algorithm for the problem below. It works and returns the desired value. However it is running slow for the size of the problem and the tool, which fixes the problems, is not accepting…
casked 6 years, 6 months ago Gabriel Santos 33 -
0
votes1
answer48
viewsHelp to understand hash usage error
I am making a program to read the words of a text file, generating a hash code to use as index that will store the word in a vector that fits up to 1000 words. Function generating the hash number:…
-
0
votes1
answer104
viewsUse a variable to limit reading of characters with fscanf and data mask
I’ve created a structure that holds three records of any kind. These records I read from an f file. They have a set size, in the case below the first dice has three characters, the second 17 and the…
casked 6 years, 6 months ago user120462 -
0
votes1
answer394
viewsdynamic matrix allocation within a struct
statement and code: Make a program that stores movies produced by various directors and: - Create and read a vector of 5 directors, each containing name (maximum 20 letters), number of movies and…
-
0
votes1
answer71
viewsError Segmentation fault (core dumped) Circular double list
I’ve been trying to make a double circular list for hours. I’ve tried to fix all the bugs but got a 'Segmentation fault (core dumped) error that I have no idea what it is. Can someone please help…
-
0
votes2
answers1083
viewsHow is the logic to print the numbers in ascending order in C
I created a code that takes a certain number set by the user, and makes the separation of pairs and odd, until then I was able to do, my problem is to put the numbers in ascending order so that the…
-
0
votes1
answer178
viewsRow function in C
I created the next queue: typedef struct No { int pos; char cpf[12]; char nome[40]; struct No *prox; } No; typedef struct No * p_no; typedef struct{ p_no ini, fim; } Fila; typedef Fila * p_fila; And…
-
0
votes1
answer1456
viewsRemove data from a C++ file
I’m making a database to store names of rock bands. But I’m not able to implement band removal separately. Can anyone help? Follow the code. #include <iostream> #include <fstream> using…
-
0
votes2
answers407
viewsList chained insertion at end
Hello I would like to know what to insert in the conditional within the function, to add the elements at the end of the list while they are different from 0... I’ve tried several ways and I…
casked 6 years, 6 months ago Raythan Machado 33 -
0
votes1
answer95
viewsHow to do arithmetic operations using directly binary in C
I’m a beginner so there might be some wrong things here. I need to do thousands of calculations with data (decimal float numbers) from several giant csv files, so I figured using direct binary in…
-
0
votes2
answers139
viewsRaw socket in C
I’m looking to make a Sniffer in C using the Socket API. I saw that a good solution was to use the raw socket: sock_raw = socket(AF_INET , SOCK_RAW , 'Tipo do protocolo aqui UDP/TCP/ICMP'); But I…
-
0
votes1
answer66
viewsWhy Does My Function Bubblebest Doesn’t Rotate?
I’m wanting to call the bubbleSort code but it does not appear to run and I can’t figure out the problem since it shows no error. #include <stdio.h> #include <stdlib.h> #include…
-
0
votes1
answer123
viewsHow to make the program stop at each printf?
I would like to make the user type a printf() at a time, being the "Name, RG and Email" but as soon as I type the name, it executes everything else and ends the program, as I make it stop in the…
-
0
votes1
answer670
viewsCould you help me invert a chained list? When reversing only the last element appears
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <new> typedef struct dados{ char nome[20]; char profissao[20]; int…
casked 6 years, 5 months ago Nayanna Nara 1 -
0
votes1
answer41
viewsCopying Files using System Calls
I’m having trouble using write(), read(), close(), open() functions to copy a text file to a new file (previously created). After some research I obtained the following code: #include…
casked 6 years, 5 months ago MarceloCosta 5 -
0
votes1
answer390
viewsProblem with calculating the mean in C language
I’m doing this exercise: 4 - Write an algorithm that reads a set of 50 chips, each one containing the height and sex of a person (1 = male and 2 = female), and calculates and prints: The biggest and…
-
0
votes1
answer48
viewsWhat is the solution to this comparison?
I am programming in C for a college subject, we must read a file and create some list methods to use in the program, basically I must implement the structure of a list and use in a solution for a…
-
0
votes1
answer889
viewsWarning: implicit declaration of Function ːstrlen' [-Wimplicit-Function-declaration]
#include <stdio.h> #include <stdlib.h> #include <strings.h> int main() { int j, vogais = 0, VOGAIS = 0, vogaistotais, tam; char a[1] = "a"; char e[1]…
-
0
votes2
answers97
viewsProblem in C IF checking
I need to know if the person is approved or failed. For the concept D and frequency greater than 75 is appearing approved but was to be disapproved. #include <stdio.h> #include <conio.h>…
-
0
votes1
answer1515
viewsInvert row with column in a matrix?
Make a program that randomly generates 20 integers in the range of 0 to 999 and fill in a matrix of size 5 x 4. Show the matrix, then show the transposed matrix (reverse row with column). I’ve…
-
0
votes1
answer71
viewsMakefile compile all files. c without specifying them
I’m trying to create a Makefile that makes all the files .c be compiled without me having to add the files line by line in the Makefile. I tried to keep up with the Creating a Makefile, but I found…
-
0
votes1
answer88
viewsError referencing Struct with Pointers
I’m trying to convert this below algorithm into c language but I’m having trouble calling the variable and assigning a value to p.key=1 of the struct element. Error Code: error: request for Member…
-
0
votes1
answer108
viewsConvert structure to string
How do I convert an integer to string? Example: convert int cod for char cod[30]. #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> #include…
-
0
votes1
answer181
viewsMalloc Function Error: sysmalloc: Assertion failed in C
I’m implementing a Red Black Tree in C, and when I allocate memory to the second node, it gives the error: sysmalloc: Assertion [...] failed. Aborted (core dumped) I have already researched and…
-
0
votes1
answer148
viewsHow to solve string printing error?
I’m passing a struct by reference to a function when entering the data, and again when printing this data. However the "Insert element" function does not read the time float (it skips the reading),…
-
0
votes1
answer33
viewsDoes not enter the function and gives fault Segmentation
Hello, please consider the structure and functions given below and the types defined. In the main function, when you enter the odd even function of the error of Segmentation fault. I don’t…
casked 6 years, 5 months ago Lucas Lopes 89 -
0
votes2
answers156
viewsI can’t get how many students approved to show up
Algorithm to read 2 notes of a student, calculate and print the final average. Right after you write the message "Calculate another student’s average 1.Yes 2.No?" and request a reply. If the answer…
casked 6 years, 5 months ago Jhonatan Pereira 1 -
0
votes1
answer56
viewsProblem in C MATRIX display
Hello, I would like help to try to solve the problem of an matrix of my program in C. It was created the matrix saying that it should be filled with such a character, it even works, but the last…
casked 6 years, 5 months ago Gustavo Duarte 1 -
0
votes1
answer47
viewsWhy is this algorithm in C returning wrong values?
#include <stdio.h> #include <stdlib.h> /* Desenvolva um algoritmo que leia 2 vetores de 10 elementos inteiros cada. Em seguida, calcule a soma desses vetores, guarde o resultado em um…
casked 6 years, 5 months ago Antonio Lopes 59