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
answer693
viewsprinting memory garbage inside the vector
Good afternoon guys, I’m starting to learn C in college, I have a job to do where I must create a code to register 5 different books (name, author, publisher) and generate a code automatically. The…
casked 5 years, 10 months ago conrado macedo 13 -
0
votes0
answers115
viewsProgram that the N numbers and printa the media, end of reading occurs when reading a negative value
With the following question to solve, I need to create a progression in c that le n positive integers compute and display the artimetica media of these, the halting condition of this loop and the…
casked 5 years, 10 months ago user127541 -
0
votes1
answer97
viewsI’m having trouble compiling a simple C program
# include <stdio.h> int main(){ int y = 5; int *yPtr; printf("Address of y veriable: %x \n",&y); printf("Address stored in yPtr variable: %x \n", yPtr); printf("Value of y: %d\n", y);…
-
0
votes2
answers95
viewsMergesort sorting algorithm error
I am having a problem with an mergesort sort algorithm in which the output of the ordered vector appears a repeated number and also a memory address. Follow the code: Mergesort /*Funcao que…
-
0
votes1
answer146
viewsDynamic stack in C does not compile because of incompatible char types
I’m making a theme in which I have to name documents in a dynamic stack, stack them and print out the names of documents. The document name is in a variable "char files[20]" in struct. I created the…
-
0
votes1
answer84
viewsMy code for the jug puzzle is not working
First of all, I want to thank everyone who reads my call for help. I’m pretty new to the C language, and I’m pretty sure I made a mistake, and I’m pretty sure I didn’t miss that code. I spent all…
-
0
votes2
answers66
viewsSetting Data Output in C
I would like the output to show the tables of each operation side by side, and not one under the other (which is the form that is printing). Here is the code: #include <stdio.h> #include…
casked 5 years, 9 months ago Fabricio Paiva 340 -
0
votes3
answers82
viewsI’m not displaying the multiple correctly
I’ve developed an algorithm that should display the largest multiple between num1 <= num2. I used as example 7 and 50 and worked correctly, displaying the value 49, but when sending for…
-
0
votes2
answers105
viewsDoubts with do-while loop
People I’m learning programming and I’m having doubts regarding the do-while loop, I was solving an exercise but at the time of executing the code presents a problem: does not end the loop, if I…
-
0
votes0
answers54
viewsDifficulty with cell array
I have to create, in C, a program that receives a train of N wagons and rearranges these wagons in ascending order from 1 to N; To rearrange, K waiting rails are used (value informed by the user);…
-
0
votes1
answer1312
viewsSimple Implementation in Dijkstra algorithm
Hello, Guys I have a little doubt. In this implementation is applied the algorithm of Dijkstra, which returns the paths of lower costs. But it is returning all of the lower cost paths, and I would…
-
0
votes1
answer55
viewsIs it a problem for me to work only with reading a file with it open in both write and read mode?
I’m starting to work with C files and need to do the skeleton of a book registration program, saving the information in a file. My question is whether I should work with the files like this, opening…
-
0
votes2
answers302
viewsError trying to access an array element
How do I make the execution of mine loop generates a registration code automatically? Error on line 36 - 'book[i]. Cod = i;' [Error] subscripted value is neither array nor Pointer nor vector…
-
0
votes3
answers246
viewsRead and print struct values
I have an algorithm that reads name, sector and number of 10 employees, I’m trying to read in a function but I’m not succeeding, when I try to print only out numbers. This is a piece of content that…
-
0
votes0
answers75
viewslinear path in c language
Hello, I’m Lísias and I was wondering if someone could help me in this difficult task to finish my library. I made a game engine, and in it I have already managed to implement all the basic…
casked 5 years, 9 months ago Lísias de Castro 11 -
0
votes1
answer89
viewsDoes not print numeric digits
1 - Crie um programa em linguagem C, que tenha os seguintes itens (0.5 pontos). a) Armazenar em uma constante do tipo caractere, o número do seu RA sem o traço. b) Criar um vetor do tipo inteiro com…
-
0
votes1
answer221
viewsQuestions about the use of C functions
I need to do an exercise that will basically ask the user to type two strings. Before that, an integer value X is entered representing the position from which the first string will be saved to the…
-
0
votes0
answers80
viewsPopular matrix in C
I have a problem I can’t solve, I believe it’s a very primary mistake. I need to popular a matrix (i,j), however, when I have the matrix printed, it gives a Bus error or Segmentation fault. Look at…
-
0
votes0
answers38
viewsC-Reading a specific amount of characters
Hey there, guys! I’m just a beginner in the programming world and I’m facing the following problem: I would like to read the name of a player that must have at least 1 and at most 10 characters, at…
-
0
votes0
answers54
viewsMatrix in memory block
Hello, everybody! I have one more question about matrices, more precisely in the memory occupation of each one. I’m trying to simulate what the guy in this video Performance x64: Cache 2 Cache…
-
0
votes2
answers241
viewsCan anyone assist in a resolution of a C code?
Next guys, I’m studying and I’m Beginner, and I have this resolution to solve and I’m having a hard time... I have to use scanf("%[^\n]%*c", s), where s is an array of char... The code must read two…
casked 5 years, 9 months ago Lucas pereira 171 -
0
votes1
answer33
viewsOne of the fgets() commands is not executed
The code runs normally until it arrives at the part where it is asked to insert the units of the component. I did not insert anything and it already closes the program. #include <stdio.h>…
casked 5 years, 9 months ago user133918 -
0
votes0
answers43
viewsCalculate the sum of the values of a matrix and store it at the first available position of a vector
I am having problems in the cycle that stores the value of the variable aux in the first empty position of the vector re and I can’t see where my error is. The value being stored is not the value of…
-
0
votes1
answer88
viewsSpace between matrix number
Good evening, I’m new to the site and beginner in C Language ,I know only the basics for now,I have a question that I’m struggling if someone knows how to solve would be grateful. I’m taking the…
-
0
votes0
answers137
viewsWhy does my SD card corrupt in the Afghan rescue?
I have a Kingston 4GB micro SD card and a Datalogger code that deletes the successful file and creates a new one with the new values of the variables. Follow the code below: void back_var() {…
-
0
votes1
answer168
viewsProgram in C closing without explanation
I am doing a C program that aims to read a list of purchases stored in a text file and add the total value of the prices of the products. In each line of the file has, the product name, the quantity…
-
0
votes1
answer47
viewsAdjust vector post element removal
So, imagine that there is already a function that registers students and there is this struct of students below and a variable that counts how many registered students we have and the constant that…
casked 5 years, 9 months ago Antonio Lopes 59 -
0
votes0
answers66
viewsOmp miscompartes in the call of the same function
Dear friends... I am a beginner in Omp (parallel programming in general) and am going through the following problem, which may be obvious. So I came to ask for help. The call is as follows #pragma…
-
0
votes1
answer159
viewsHow to add a string to a C file?
I am having a hard time passing a string to a C file. It turns out that every time I try to write something to be sent to the file, not all the desired information appears. #include<stdio.h>…
-
0
votes1
answer154
viewsDo you need to allocate memory when you have struct inside another struct?
I want to save and recover data from a struct, but this struct has other struct inside it, I don’t know if I did it correctly, I don’t know if I should use typedef or just struct. I don’t know if I…
-
0
votes1
answer89
viewsHow to loop with invalid object message?
I am only doing this program to train, and I want to print a message saying "invalid object" if what I type is different from the solids that will be declared in the variables, but with a loop while…
-
0
votes0
answers36
viewsDoubt about code reading in C
I have a question about a code I made in C, the statement is as follows: "Write a C algorithm that reads the Price of a commodity and displays the price on the reset screen of 3%. The user will…
-
0
votes2
answers1331
viewswrite struct to file
I’m trying to record a struct in a file via language c. But whenever I run the program on xcode nothing is recorded in the archive. I have tried the file permissions system, but there is nothing…
-
0
votes1
answer59
viewsGenerate a context from another instance in Createview
Hello! I need to render a context in the Createview template. no requeste to passing an id, and I want to put the name of that id in the Createview template py.url urlpatterns = […
-
0
votes0
answers36
viewsSimple program to calculate school averages in C with vector
Hello, I am trying to run a small program that I would like you to read a certain average, store 4 student X grades, calculate the average of those grades and compare with the minimum average grade…
-
0
votes0
answers53
viewsDifficulty with dynamic struct allocation
The question is : implement a type of Tbaralho dice to represent a pile of cards. Your data type should store the cards in the deck and the amount of cards present. Consider that the maximum size of…
-
0
votes0
answers54
viewsHow to solve segmentation failure (recorded core image) in recursion?
I’m having trouble with this part of my show. I have to do a function with the Bron-Kerbosch algorithm, but it is giving the following error: segmentation failure (image of the recorded core) and I…
-
0
votes1
answer44
viewsBeginner Doubt - Loop Error
Guys, I’m doing an exercise, but something is giving conflict in this little bit of repetition, da para colocar as primeiras informações do primeiro Loop, but when it goes to the second, it skips…
-
0
votes2
answers53
viewsHidden value of variable
When I put to show the numbers that were exchanged the program just shows nothing, I do not understand why. Read two numbers by storing them in the variables num1 and num2. Check if the value of…
-
0
votes1
answer35
viewsSegmentation failure using realloc function
Hello, I have a function that should receive values from an intersection and if you enter a value I should relocate more memory and return this pointer. Analyzing the problem, it seems to me to be…
-
0
votes0
answers64
viewsWhile Infinite Loop in C
I’m trying to make a linear list with chained allocation in C and I’m falling into an infinite loop. void busca(Lista L, int x, No* ant, No* pont){ No ptr; *pont = NULL; *ant = L->ptLista; ptr =…
casked 5 years, 7 months ago GiovanniFilho05 1 -
0
votes2
answers59
viewsDoubt Exercise - Academic
My question is in the letter B, I am asked to count between the first 20 terms, how do I do this limitation of 20 terms of the account? I even put the formula in is (i = 5, j = 3; i += 2, j += 2)…
-
0
votes1
answer28
viewsWhile Repeating Structure Problem
I have this exercise to do but I’m not getting it, it asks to use while but how will I save the data since I do not know the amount of variables for each book, since the amount of books varies for…
-
0
votes1
answer67
viewsHelp: structs and pointers for C pointers
Hello! I need some help! I’ve been trying for a while to do a pointer study for pointers in structures but so far I haven’t been able to reach a conclusion (it always gives "segmentacion fault").…
casked 5 years, 7 months ago Fulwondel Irmage 1 -
0
votes2
answers1167
viewsInsert an empty space between a concatenation of strings in C, without the string library. h
I am implementing this code in order to receive two strings and compare them, if the two strings are different I concatenate the two into one vector, but I want to add a blank in them. How can I…
-
0
votes1
answer388
viewsMultiply even index values of a string in C
The question I need to solve is the following: The person gives a number, I need to multiply by 2 all the numbers that are in the "index" even, the problem is that the index starts at 1 on the…
-
0
votes1
answer113
viewsProblem with the use of float in vector C/C++
I need to do the following problem in C: Read 12 valid student grades and store them in an array of notes. Assuming that there may be errors in the typing process, some values stored in the vector…
-
0
votes1
answer32
viewsProblem with memory allocation for the second time
well, the program works correctly in the first for loop, but in the second it hangs when trying to allocate "q" for the second time. follows part of the code: void Insere(Poligono p, double x,…
casked 5 years, 6 months ago michel brito 3 -
0
votes1
answer51
viewsVector pointer with dynamic allocation in C
I managed to do this exercise inside main, however the same concept has not worked when using functions. The aim of the program is simple, read six values and display them. #include <stdio.h>…
-
0
votes1
answer50
viewsSegmentation failure - C
#include <stdio.h> #include <stdlib.h> #include <string.h> int validaTipo(char t); typedef union{ struct contratoIndividual{ unsigned int…