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
answer111
viewsStructure of Data/ Stacks
People need to do a battery exercise that receives String, in which in the first line I have to include the size of the stack and in the others go giving the commands, example : Entree: 5 And…
-
0
votes1
answer130
viewsHow to mount a BMP header (Bitmap) in C
Hello. I’m looking to build a BMP in C-language. I only receive image data, data size, width, height, bpp. I was able to mount the following header structure of BMP: struct BMPHeader { uint16…
-
0
votes2
answers215
viewsWhy can’t I pass a matrix as a parameter of a function in C?
Dear friends, today I have come across a problem I cannot understand. When trying to pass an array as a parameter, I cannot access the values of the elements, I always access the memory addresses of…
-
0
votes1
answer36
viewsAdd initial value to a linked list
Good night. I am implementing a linked list and wanted to do a function to add to the bottom of the list an element, in that function I wanted to check if the list is empty and if so add the first…
casked 5 years, 6 months ago Fábio Silva 13 -
0
votes2
answers109
viewsError with memcpy and memset
Could anyone tell me why this problem occurs below? It does not copy the last position of the pointer vector, with the value 57, to another pointer vector. This intrigues me, why not copy this last…
casked 5 years, 6 months ago Bianca Nunes 103 -
0
votes1
answer522
viewsCounters in the Mergesort
I would like to know where I need to insert my variables that count exchanges and comparisons. In this algorithm I am dealing with an array of two positions that by reference modify details[0] that…
-
0
votes1
answer241
viewsHelp with Struct and File Manipulation (C)
Hi, I need you to help me... I did this algorithm to register the "interviews" of employees, and whenever I want to fetch an employee, I simply put his name and all the data relating to him appear.…
-
0
votes1
answer53
viewsWhy are you returning "Invalid Position"?
When I type 3, instead of asking for the Position I want to enter, it returns 'Invalid Option'. Could anyone tell me why? Follow the code: #include<stdio.h> #include<stdlib.h> int…
-
0
votes1
answer38
viewsC code does not show full list
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<locale.h> int main() { struct aluno{ char nome[30]; int n_matricula; char curso[30]; }; struct aluno…
casked 5 years, 6 months ago Julio Faria 21 -
0
votes0
answers32
viewsVector memory allocation of int inside a struct
My structures are defined this way: typedef struct{ Medicoes *medi; unsigned int numeroMots;//comprimento de mots diferentes, nao repete int *mots;//MOTS existentes na room int compMots;//omprimento…
casked 5 years, 6 months ago Fábio Morais 1,522 -
0
votes2
answers123
viewsPartitioning in C
I have to do an activity in which I must type in the input the size of the vector, the position of its pivot, and then type the elements that make up this vector input example: 7 - vector size 1 -…
-
0
votes2
answers37
viewsRedefining how a function operates? C
Hello, I have a question regarding a line of code below, see: #include <stdio.h> typedef float (*TPonteiroFuncao)(float, float); // O QUE ESSA LINHA FAZ? float soma(float a, float b){ return…
-
0
votes1
answer207
viewsI can’t make the scanf work
I’m trying to learn C and today I made a very simple program that requests basic personal data and then it needs to print this data on the screen. I put 5 items to be requested and he only requests…
casked 5 years, 6 months ago Vitória Oliveira 11 -
0
votes1
answer52
viewsList does not print in C
My code is compiling, but why doesn’t my list print? Code: #include<stdio.h> #include<stdlib.h> struct numeros{ int num; }; typedef struct elemento* Lista; Lista* cria_lista(); void…
casked 5 years, 6 months ago Guilherasmin silva 47 -
0
votes3
answers2698
viewsSeparate even and odd numbers with two vectors in C
I have the following problem: I need to read several numbers until the number typed is 0 or one of the vectors is fully filled, in case the vector must have a maximum of 10 indexes, and for each…
-
0
votes2
answers2087
viewsProblem with perfect number in C
I’m having trouble showing if the number is perfect, when I put in 6, it says it’s not perfect, and I can only use pointer and dynamic allocation. Someone would know how to help me? #include…
-
0
votes1
answer559
viewsRequest for Member 'name' in Something not a Structure or Union - Error
#include <stdio.h> #define MAX_VETOR 6 const int na = 1; typedef struct { char nome[10]; char sexo[1]; } tp_pessoa; typedef struct { tp_pessoa *pessoas[MAX_VETOR]; int inicio,fim; } tp_vetor;…
-
0
votes1
answer76
viewsWhy can’t I print out what’s on the list?
#include <stdio.h> #include <stdlib.h> #include<conio.h> typedef struct cadastro { char nome[30]; char matricula[30]; char Disciplinas[30]; char notas[30]; struct cadastro *proxno;…
casked 5 years, 6 months ago Guilherasmin silva 47 -
0
votes0
answers43
viewsI got an error trying to create my matrix. Error: Warning Passing argument 1 of " " from incompatible Pointer type
I’m trying to create a code with a 3x3 matrix. However, I haven’t touched C for a while and I needed to review this content. I believe that the failure of the program is some question related to…
-
0
votes1
answer73
viewsWhy are the values of x and v[0] not equal? - C language
I’m reviewing some concepts on the site : Addresses and Pointers, until I find the following code: void func1 (int x) { x = 9 * x; } void func2 (int v[]) { v[0] = 9 * v[0]; } int main (void) { int…
-
0
votes1
answer142
viewsTotal count of characters without strlen
I need to count the total number of characters present in any word without the function strlen(). First I performed the word reading, after using a for to go through the word, within the for I used…
-
0
votes2
answers84
viewsForm with Struct and Pointers
Guys, I made this program to receive name, address and phone of 2 people, he receives the data of the first people quietly, problems begin with the data of the second person, the name and address of…
-
0
votes2
answers1331
viewsIntermediate vectors in C
People have to develop a code that reads the size of 2 vectors dps the elements of it (these vectors are increasing), transform into a single vector (it doesn’t have to be ordered), and then using…
-
0
votes1
answer87
viewsHow do I get the position the user wants?
It works like this, I want to get all the possibilities of playing the horse in chess, but how do I know the position the user wants? How do I do? I don’t know much about c. Actually with…
casked 5 years, 6 months ago Henrique Ferreira 19 -
0
votes1
answer985
viewsHow to print a string in C?
I’m studying C and I want to make an algorithm that reads the names of 30 students in a class and returns the highest grade, lowest grade and the names of these students. I have already researched a…
-
0
votes1
answer169
viewsfree() in char dynamic stack does not work - C
Hello, I’m having trouble trying to release dynamically allocated memory. For small string there is time that works, but for large string the program tops. There’s a time when a 3-character or…
-
0
votes1
answer621
viewsVoid pointer in C
Write a program in C that reads 2 numbers (integer or real) and prints their sum. The user informs what type of data will be entered. Note: Use only pointers and dynamic memory allocation to solve…
-
0
votes2
answers4555
viewsPrime numbers in C
I started programming recently and soon they gave me the problem of creating an algorithm to check whether a number is prime or not. As at the time I was still having some difficulty in looping…
casked 5 years, 6 months ago Felipe Delite 3 -
0
votes1
answer45
viewsArray values are reset when displaying
Guys, I have this simple code in C and I’d like to know why I’m trying to display the total array and the value that’s returning me is 0, if I put this printf inside the first while the values are…
-
0
votes2
answers263
viewsHow can I pass a parameter of any type to a generic vector? - C
I have a structure like TTabelaX, which is basically a table that I will store elements of any kind, ie I can create a table to store a type element TCarro, with plate and color, then I can use the…
-
0
votes1
answer376
viewsError in income tax program in C
I developed the following program in C for an income tax calculation of employees of a company #include <stdio.h> int main(){ //Declaração de variaveis int depen,cont,a1=0,a2=0,a3=0,a4=0,a5=0;…
-
0
votes1
answer128
viewsTrying to build a graph
Well, folks, I suppose my problem is pretty simple, but I’m having a hard time, so if you could help me I’d appreciate it! What I want is the following: create a vector that can allocate several…
-
0
votes1
answer69
viewsSegmentation failure (recorded core image) decimal to binary conversion
#include <stdio.h> int main() { int d; int bits = 8; int vetor[bits]; int a = bits - 1; int b = a; scanf("%d", &d); if(d >= 2) { while(d/2 > 0){ vetor[a] = b % 2; b /= 2; a--; b--; }…
-
0
votes1
answer114
viewsVariable does not display correct result in C
I have the following problem to solve: Write a program that reads two matrices of 10 rows and 2 columns. Each row of the matrix stores two notes of a student. The first matrix stores the notes of G1…
-
0
votes1
answer259
viewsLogical error when sorting vector in pair and odd
Well, I was trying to sort a vector in even and odd, that is, half the vector is even and the other odd. It worked "almost" perfectly. The problem is that the last position always ended up being…
-
0
votes1
answer229
viewsProblems in C , storing several different values and doing arithmetic media
I have a doubt, I have a programming work to do, but the problem is somewhat complex. My question is: How do I store several different values and do arithmetic media. I was able to calculate the…
-
0
votes1
answer52
viewsFunction in C does not return the number squared that the user computed
I’m learning C and data structure, I’m using a workbook (https://docs.google.com/viewerng/viewer?url=https://api.apostilando.com/pdf-Viewer.php? pdf%3D3353_structure_data.pdf), I think I’m having…
casked 5 years, 5 months ago Devprogramacao 119 -
0
votes1
answer146
viewsChange the quadrants of an even-sized matrix
I get an array, and I must print it on the screen as shown in the image below. This is the current code: #include<stdio.h> int main(){ int matriz[4][4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,…
-
0
votes1
answer60
viewsRead quantity until you reach -1
I worked in this exercise of the facu: MAKE a program with a method ( exercicio06 ) to: read two integers (a) and (b) from the keyboard, read other integer values from the keyboard one at a time,…
casked 5 years, 5 months ago Bruna Ferreira 1 -
0
votes2
answers825
viewsDivision error by zero
I am a beginner in programming and I have to assemble a code in which I put two values and the program gives me the result in sum, subtraction, multiplication and division, but when dividing a…
casked 5 years, 5 months ago José Dutra 3 -
0
votes4
answers65
viewsBeginner program error in C
I am starting to program now and I have a problem in the example below. The question asks to calculate the income tax, according to the salary received by the person. The mistake is that, regardless…
casked 5 years, 5 months ago use_-44-18 13 -
0
votes2
answers477
viewsI need help to calculate the factorial in ascending and descending order in an equation!
I need to resolve this question: Make a program that reads the number of terms and a positive value for X. Calculate and show the value of the following series: * S = (-X2/! 1) (+X3/2! ) (-X4/3! )…
-
0
votes2
answers78
viewsDid I use the if and Else wrong?
I started programming a little while ago and I’m trying to learn C but I came across a mistake that I can’t solve. #include <stdio.h> #include <stdlib.h> #include <math.h> int…
casked 5 years, 5 months ago Izaac Borges 15 -
0
votes1
answer56
viewsCode not working
I’m trying to solve a problem of the site Urionlinejudge (problem link) and I’m getting a mistake like Time limit exceeded, and I’m having trouble identifying the problem. I can imagine that it is…
-
0
votes2
answers60
viewsMatrix initialization not working from a given line
I need to initialize a matrix that contains the binary values from 0 to the input value, which in this case is 15. The base conversion and the storage of these values works well until the number 8.…
-
0
votes1
answer288
viewsMatrix Binaria in C
I need to initialize a matrix that contains the binary values from 0 to the input value, which in this case is 15. The base conversion and the storage of these values works well until the number 8.…
-
0
votes1
answer131
viewsC Language - Read File to Save to Lists
Imagine a school with several classrooms, and each room has several students I’m having trouble reading file with the name of the room, number of places by rows (rows and columns) I have the…
casked 5 years, 5 months ago João Pereira 29 -
0
votes3
answers81
viewsHow do I resolve this error by trying to delete a specific node from a chained double list?
In my project, I am making a double-padlock list in C, where it has simple objectives, such as adding at the beginning or end, removing a specific or zeroing. I took a shallow code and was adding…
-
0
votes1
answer925
viewsSeries of Taylor for cos(x) - in C
I’ve been trying to calculate this sum, but I’m having trouble making the factorial work... someone can help me identify my mistake? . Where x is the angle in radians and N the number of terms of…
-
0
votes2
answers264
viewsProblem decreasing the size of a stack in c
This program is an exercise to work with stacks, it’s all right, but when I decrease the stack size to exclude the last term it appears in the penultimate element of the vector. #include…