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
-
1
votes1
answer325
viewsPower Building Exercise in C
I’m starting to learn how to program, so forgive me any more silly mistakes. It’s a simple exercise, doing a C power by setting the base and exponential. Here’s my code: #include <stdio.h> int…
-
1
votes1
answer336
viewsHow to compare characters from an external file to the ASCII table in C?
I need to make a program in C that reads an external file with characters inside and checks if the character code is between the codes >32 and <126 of the ASCII table. If it is between code 32…
-
1
votes1
answer332
viewsCount number of lines in the file
Good morning,this function counts the number of lines of a file,but it has a little problem,it only counts the line when it finds the n,for example to test it,I would create a text file,and write a…
-
1
votes1
answer212
viewsHow to write a string variable without breaking the line?
I need to write only in the first line of a file, but whenever I add a string type variable this line is broken, follow the example: #include <stdio.h> #include <string.h> char…
-
1
votes1
answer100
viewsInput with fgets
Hello, I’m having the following difficulty, the moment I call the function of fgets, regardless of whether on any parole, or in the registration function it does not work. At the moment when…
-
1
votes0
answers35
viewsIs it wrong to build a program with only one . c and several . h file?
I am making a program in C and decided to implement the functions that are declared within the files . h without using. c files of the same name. I have a design structure similar to that: /src…
casked 4 years, 9 months ago Gustavo Moraes 19 -
1
votes0
answers51
viewsHow to show 3 data at a time in this printf in C language?
I have the following code: //Leitura de arquivo #include <stdio.h> #include <stdlib.h> int main(void) { FILE *pont_arq; char texto_str[20]; int contador; //abrindo o arquivo_frase em…
casked 4 years, 8 months ago Mayara Rabelo 19 -
1
votes1
answer1445
viewsCompile project with multiple files . c in Vscode - C language
Good afternoon, I’m having trouble separating my code into . c and . h in Vscode. Follows the implementation: main. c #include "head.h" int main(){ printar(5); } head. h #include<stdio.h>…
-
1
votes1
answer137
viewsHow to get a program running in C without looping and compiling again?
# include <stdio.h> int main () { int Senha, Tentativa; int Contador_De_Erros = 1; printf("Vez do jogador 1 jogar\n\nLembrando que a senha tem que ser um numero entre 0 e 100\n\n");…
-
1
votes1
answer86
viewsProblem for centralized printing in C
I have the following problem, in my code I want the program to centrally print the number 1 after the "word", and to center I am using the parameter "%-20s \t" to try to center the number after the…
-
1
votes1
answer67
viewsWhat’s wrong with this array of pointers in C? (incompatibility?)
Hello, recently I was doing a relatively simple test to try to unify some concepts I have been studying, and which you will see below. It is an array of pointers that I used as a parameter of a…
-
1
votes1
answer35
viewsprogram in doubt - search within for
Hello! I am a computer science student and I am developing a library program with menu. The program works all that is a beauty by exception of one thing... When I do a search by author I cannot…
-
1
votes2
answers79
viewsError in C program compatibility between float and float pointer
I need to pass a float vector for a function that dynamically allocates memory and then returns this inverted vector. However, my code tells me that I have an error here: program. c: In Function…
casked 4 years, 7 months ago GratefullyDead 373 -
1
votes3
answers89
viewsWrong calculation of percentage
How exactly is it made to use the switch correctly? Here in the code, the case 1 and 2, they function normally, but in case 3 and 4, at the time of division by 2, or by 3, to know the plots, always…
-
1
votes1
answer72
viewsHow does access to struct by pointer pointer and by a copy of the pointer work?
In push1() I passed by parameter the memory address, on push2() I passed a copy of the pointer, but I didn’t understand the difference how each one accesses the struct? struct Node { int data;…
-
1
votes0
answers60
viewsComparing two strings in C
I’m having a problem knowing which position the user’s CPF is registered in the user’s struct array, the problem is that when I compare lista_usuarios[i].CPF == cpf_recebido never appears. Code I’m…
casked 4 years, 6 months ago Everton Figueiredo 520 -
1
votes0
answers54
viewsProblems with Binary Tree Search Tree Removal in C
I’d like your help with a binary search tree code. I already have all the code, but I’m having trouble with the removal of a knot with a child. I’ve looked at the analysis of that same code that I…
casked 4 years, 6 months ago FernandoHCA 11 -
1
votes2
answers200
viewsgetchar() command used several times
#include <stdio.h> #include <stdlib.h> int main(){ char c1, c2, c3; printf("Digite um caractere: \n"); c1 = getchar(); printf("Digite um caractere: \n"); c2 = getchar(); printf("Digite…
casked 4 years, 6 months ago Henrique Hott 23 -
1
votes1
answer56
viewsIncorrect link in C program and Assembly
I did an Assembler routine to calculate the exponential. I compiled it, and I get the Object Exp file. o The C++ program to take advantage of this routine is the type of: #include <iostream>…
-
1
votes2
answers78
viewsAccess vector value by index
I’m practicing a little vector, when I come across this code, of an exercise: #include <stdio.h> main () { char ex3[5] = { 'z', 'k', 'w', 'x', 'v' }; int cont1; cont1 = 2; printf ("%c…
-
1
votes2
answers33
viewsArray as a function parameter
My program stores 10 numbers in a vector and Zera the numbers that are less than 0. I am receiving these two error messages: Passing argument 1 of 'Zeranegativos' makes Pointer from integer without…
-
1
votes2
answers237
views -
1
votes1
answer98
viewsHow to improve this code? Simple Question in C
I have a question asking to calculate a due value of each car by parking and print on a tabular exit, ex: Carro Horas Valor 1 2.0 2.0 2 3.0 2.0 3 4.0 2.5 TOTAL 9.0 6.5 I was basically having trouble…
casked 4 years, 5 months ago Pedro Vinicius 43 -
1
votes0
answers352
viewsHow to compare values within a single vector? IN C
I made my code as follows, as placed below. However, if I put 2 repeated numbers it says it has only 1 repeated number, if I put 4 repeated numbers, it says it has 6 repeated numbers.I no longer…
-
1
votes1
answer54
viewsHands with variable float and char
I am unable to assign an address to a pointer variable when it comes to float or char variables, the visual studio brings me the error "C++ a value of type cannot be Assigned to an Entity of type".…
-
1
votes2
answers157
viewsCalculate the number of characters of the largest word in a file
The file is written as follows: palavra0palavra0palavra0 Since the words are different. The problem is to calculate the size of the largest word that appears between the zeroes, and the file can…
-
1
votes1
answer56
viewsSubroutine in C does not execute
The goal of the program I’m creating is to receive the distance that 15 cars (simulated with 3 to speed up the test process) traveled during the day. Distance can be reported in kilometers, meters…
-
1
votes1
answer1308
viewsIntersection of vectors in C
In the code below the intention is to intersect two vectors, but when it does not check if the value is 0 in that passage if(vet1[i] == vet2[j]) { n = vet1[i]; }else { C[i] = '\0'; } I check if the…
casked 4 years, 5 months ago Arthur Pereira 13 -
1
votes2
answers1848
viewsRecognize enter key in C
I’m trying to make a code that only prints the third to a typed string, but my program is endless, how to recognize the given enter for the program to end? #include <stdio.h> #include…
-
1
votes2
answers342
viewsError exited, Segmentation fault in C
I’m trying to make a function that returns me a date according to an integer and always appears the error: exited, Segmentation fault The code I created is basically this: #ifndef DATA_H #define…
-
1
votes0
answers25
viewsThe impression is not coming out the right way
I’m doing an activity (Develop a program in C language that reads this dataset (CSV) and sort it based on the first column.) where I have to read a CSV file, and have to sort using Bubblesort, the…
-
1
votes1
answer105
viewsFor in the C language
I studied the iterative artifice for and thought the same applied to the following example: for(i = 0; i < 7; i++){Código} However, when studying the pointer part with vectors, I came across the…
-
1
votes0
answers40
views(training/beginner) Problem with segfault in fread() and fwrite() in . txt!
Whoops, you guys! First I wanted to say that I am very beginner and self-taught. I started with CS50 and I’m on the walk, rs. Contextualizing the code: 1x a week I work at an organic fair and I need…
-
1
votes3
answers138
viewsThe main function and its arguments. How does it manage to assign to its argc and *argv[] arguments the parameters passed via terminal?
For my question to be clearer. Suppose my program, called main, needs to receive any number of console parameters. To do so, I would have to do it. int main( int argc, char *argv[] ){ ... return 0;…
-
1
votes2
answers326
viewsProblems with pi approximation algorithm in C
Good evening, I’m having the following problem, I’m developing an algorithm to calculate a pi approximation. #include <stdlib.h> #include <stdio.h> #include <math.h> #include…
-
1
votes1
answer398
viewsCalculation of cubic root in vectors
Hello! I am doing an exercise where it is necessary to calculate the cubic root of 10 numbers stored in a vector and transfer them from vector A (where the numbers were read) to vector B ( where…
-
1
votes1
answer61
viewsProblems when deleting the first element from the chained list
Dear friends, for example, I am using a list simply chained, without head and I need to write a function to delete an X element in the list. I made the following code: #define Limite 21 typedef…
-
1
votes0
answers118
viewsRead 15 elements in a matrix A type vector. Create matrix B be the factorial of the corresponding element of matrix A
Read 15 elements in a matrix A vector type. Create a matrix B of the same dimension, where Each element of the matrix B is the factorial of the corresponding element of the matrix A. Display the…
-
1
votes0
answers18
viewsInsertion at the end of a TAD List
Hello I would like to know what to insert in the conditional so that the same occurs the insertion of the data in the end of the list, not at the beginning. #include<stdio.h> typedef struct…
-
1
votes0
answers14
viewsCasting of malloc return in string matrix
The objective of the program is to inform the number of days, hours, minutes and seconds corresponding to the number of seconds in the input. If the value is less than zero, the output should be…
-
1
votes1
answer54
viewsWhat am I missing when using EOF in this case? C language
I’m doing an exercise that basically asks to enter multiple lines of product data for a trader, but does not specify when to finish the repeat loop. In other examples you had how, for example, to…
casked 4 years, 1 month ago Gabriel Freitas dos Reis 21 -
1
votes1
answer51
viewsReturn string format from another struct
I wanted to return the formatted string, which is created in the function des_Desconto, to format another string of the function itm_showItem more does not return anything. Struct item struct item{…
-
1
votes3
answers170
viewsHow to query a struct array in C after you have already written on it?
Hello, I want a help I am making a program that has a menu the registered user and then consult the registration, the problem and I am not being able to consult the "database" vector of structs. The…
-
1
votes1
answer323
viewsDescribe the averages of each row of a matrix in C
Work out an algorithm that reads a 3x3 matrix of real numbers and calculates the mean of the values of each matrix row. #include <stdio.h> #include <stdlib.h> int main() { int i, j;…
casked 4 years, 1 month ago RAFAEL FELISBINO ROCHA DA SILV 11 -
1
votes2
answers229
viewsHow to receive a character array in C with for?
Considering Mxn as 2x2, I need to receive in each Mxn position a character. for example: r d g h for(i=0; i<m; i++){ for(j=0; j<n; j++){ printf("Digite um caractere para a posicao %d x %d da…
-
1
votes1
answer159
viewswhile for loop with scanf
I’m trying to make a report in c, and when I type the first character the program ends. #include<stdio.h> #include<string.h> #include <ctype.h> #include<conio.h> #include…
-
1
votes0
answers36
viewsError of Conflicting types for 'login'
I’m making a login screen, but my code is giving error: Conflicting types for 'login'. I’m a beginner in the area and I’m not able to understand what to do to fix this, someone could help me?…
casked 4 years ago Larissa Araujo 11 -
1
votes0
answers34
viewsMutex ignoring time out without having given release (windows)
Hello! I’m developing a sort of local server with door access to a college paper. What limits the amount of users on this server is a mutex, where only one client at a time must connect to the…
-
1
votes1
answer111
viewsChange volume of a WAV file to C
I’m trying to make a volume change in a WAV file that I just don’t understand because it’s not right. I am a beginner and ask you help to understand the volume pq get very burst and noisy when I try…
-
1
votes1
answer88
viewsRemove() function does not delete the file in C
I am trying to delete a file and soon after rename another file, but it turns out that the remove function does not erase the file. I tested on two machines, giving full permission, but without…