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
votes2
answers98
viewsContinue "do while" from last point
There is a registration program that I must perform, I put the registration options and etc. All the code is saved in the vectors and are as expected, but when I return to main(), it goes back to…
-
1
votes1
answer132
viewsWhat is the difference between *variable and *variable-'0'?
I’m writing a Sudoku game with C and ncurses, below follows the code of a function that receives a pointer to a variable (ch) which stores typed key with function getch(), if the number already…
-
1
votes2
answers672
viewsRecursive function
Can anyone help me with this recursive function? It’s for her to calculate the maximum common divisor between two numbers but I don’t know what’s wrong with my function. int mdc(int m, int n){ int…
-
1
votes2
answers87
viewsConditional does not work as expected (related to ASCII table)
int tam, i; char msg[1000]; printf("Escreva a mensagem para ser criptografada: "); fgets(msg, sizeof(msg), stdin); tam = strlen(msg); for (i=0; i<tam; i++) { int aux; aux = msg[i]; if…
-
1
votes0
answers39
viewsProblem with program to reverse WAV audio in C
I’m making a program to reverse (let it go) a WAV audio given as input, but my program stops working and I can’t find where I’m going wrong. Follows my code: header: #ifndef WAV_H_ #define WAV_H_…
-
1
votes1
answer97
viewsFunction that is not running in C
This is a code whose goal is to add all the integers between a and b. Being "a" less than "b". The expected output was a number representing this sum, however, after reading a and b, nothing…
-
1
votes1
answer66
viewsProblems in String and Case
I’m a beginner in programming for a little while and I have a college task in which I must create a registration system that receives the entries the customer data and then another option that…
-
1
votes1
answer81
viewsStruct receiving the same struct as attribute
Hello, how can I have a "recursive" struct? A struct that takes itself as one of the attributes. typedef struct { int value; NODE[50]; } NODE; In this case, the idea is that each Node has a vector…
-
1
votes1
answer86
viewsHow does this function work?
It’s part of an sorting algorithm, reading the code made it seem to me that the function never makes the call: sort(mid+1, high); gets into loop at first sort(low, mid); until you leave the if, and…
-
1
votes1
answer131
viewsI need to match a string matrix to another matrix, how do I do?
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 3 #define LEN 80 char texto[MAX][LEN]; int main(){ char string[MAX][LEN]; …
casked 7 years, 1 month ago Braian Freitas 159 -
1
votes1
answer104
viewsWhy can’t I get a read on that Cyborg?
I’m new to programming; that’s the question: Having as input the name, height and sex (M or F) of a person, calculate and show your ideal weight, using the following formulas: • for men: ideal…
-
1
votes1
answer58
viewsLanguage C - Summation problem within a function
Good afternoon. The purpose of the programme is as follows. I have to have the user type in how many students the classroom has, so that it sends this number to a function (in this case, each…
casked 7 years, 1 month ago Bruno Noveli 51 -
1
votes0
answers146
viewsProblem with serial interruption USART UDRE for Atmega328p
I’m having trouble using USART serial transmission interrupt in a program made in pure C and run in Rduino (Atmega 328p). My application requires pure C for reasons of efficiency and speed, but…
-
1
votes3
answers6982
viewsCalculate the standard deviation of a vector
I’m having trouble solving the following equation: Here is the code: #include <stdio.h> #include <math.h> int main(){ float m, media, sigma, p; int vetor[10]; media = 0; m = 0; sigma =…
-
1
votes1
answer131
viewsWhat is the name given to an unsigned "overflow"?
Considering that answer in Soen would like to know what the nomenclature of when it occurs to try to store a value greater than the type unsigned int can contain as the result will be module…
-
1
votes3
answers833
viewsI’m trying to get a C on file, but the code won’t let me enter the address
I’m trying to register in C, but the code does not let put the address and when I put the option to finalize the registration the program hangs and stops working. What am I doing wrong? #include…
casked 7 years ago Clarissa Galvao 43 -
1
votes1
answer318
viewsHow to return integer value in pthread?
How to return an integer value and be able to show with printf using pthread ? Follow an example of the problem : #include <stdio.h> #include <unistd.h> #include <stdlib.h>…
-
1
votes0
answers47
viewsDelete a user from a C.dat file
Well, I need to do a program where I create a basis to archive login data from a "company", I’m still very new to the concept of c but, I’m not able to do the part where I delete a user from the.dat…
-
1
votes1
answer369
viewsWhy . dat and not . txt?
I’m doing a job for my college in C language, it would be basically the entire shoe store system, with file manipulation. Looking for some examples of CRUD on the internet I found several that make…
-
1
votes1
answer131
viewsWhat error? Strtok C
I made the following code that takes a string of 3 numbers separated by space, then delimits them and allocates each number in an array position, at the end it prints the array, the code works but…
-
1
votes1
answer238
viewsDoubt in a matter of C pointers
That’s the thing about: Build a function that takes two integer values a and b, returns (passing by reference) the quotient, div, and the rest division, mod, of a for b. The function must return -1…
-
1
votes1
answer82
viewsHow to add in a program that runs at the command prompt in C
I’m doing my first C programming project, and it’s a card game. The problem is that I do not know how to add the symbol of suits to run at the prompt. They are not in the ascii table, but I know it…
casked 5 years, 5 months ago user154000 27 -
1
votes1
answer57
viewsShow as many possible combinations
#include <stdio.h> void main() { int x=10; int y; int numero; printf("quantos digitos tem sua senha: "); scanf("%d", &numero); y = numero * x; printf("sua senha tem %d combinacoes…
casked 5 years, 4 months ago Ryan Gustavo Naressi Sinatra 13 -
1
votes0
answers145
viewsConcurrent programming
Hello, I’m having trouble finding the error in the code below. It is a problem where ideally, having 5 vacancies available, any one of the types of threads (server or trainee) can be sit freely, but…
-
1
votes0
answers423
views -
1
votes0
answers58
viewsvector/dynamic queue segmentation failure
Hello, the following code is in segmentation failure. Basically I can’t scan this entrance: ISCOD4 2 3 10 20 1 10.1.1.151 10.1.2.151 10240 1 2 10.1.1.153 10.1.4.152 12288 2 3 10.1.1.156 10.1.4.153…
-
1
votes2
answers101
viewsHow to handle printf in C language
Hello! How do I put something after the variable in a printf. Ex: printf("Digite um valor para a posição: [%d", l); printf(" ,%d", c); printf(" ]"); I am using the example above, but I was wondering…
-
1
votes1
answer171
viewsCan anyone help me assign value to the positions of this matrix with pointers?
Hello, I am doubtful about the following code, it creates a two-dimensional matrix using pointers, the command line that should assign specific value to each position of the matrix seems not to…
-
1
votes1
answer303
viewsHow to make a pointer point to NULL?
I need an element position in a dynamic vector to be empty, so I can check if I can place an element inside it later. However, the compiler does not allow it. Follow my code: MATRIZ_ESPARSA…
-
1
votes1
answer325
viewsAddress type Struct for INT
I have the following Struct: struct nodo{ int elo_a; char nick[26]; char cidade[16]; int idade; int elo_p;}; I have both struct assignments: struct nodo *variavel; struct nodo *offline; Ok, I…
-
1
votes1
answer2339
viewsWhat is the Definition of NULL in C?
I was studying with my friend, and we are breaking our heads because we do not know what exactly the NULL function is! Because in every program that we see, NULL can serve in another way, I’m going…
-
1
votes1
answer34
viewsSegfault no fwrite. Why?
Why is this program giving segfault? struct{ int matricula; char nome[50]; }Aluno; int main(){ FILE *arq; if((fopen("alunos.txt", "w")) == NULL){ printf("Nao foi possivel abrir o arquivo.\n");…
casked 7 years ago Vinicius Barbosa de Medeiros 331 -
1
votes1
answer24
viewsArticle name does not let enter
I want to enter the name of the article only that it does not allow, I already made the same way the scanf as the name of the supplier but does not allow to enter equal #include <stdio.h>…
casked 7 years ago Sergio Nunes 351 -
1
votes1
answer90
viewsPOSIX - problems to write to file using open and write
About this code below, is giving write problem, but if I use creat without flags it runs. The goal is to copy a file, the file that will be copied is called 'test.txt' and what will be created…
-
1
votes0
answers22
viewsDiagnostic in Code Retrieving JPG’s from File
In a course exercise I have to write a program that recovers JPG images from a file. The code below is not ready, but it should find the signatures of JPG (0xffd8ffe0 or 0xffd8ffe1) inside the file…
-
1
votes0
answers718
viewsURI Issue 1463 in C, I cannot identify the problem in the code
I’m trying to solve URI Online Judge Issue 1463, link: https://www.urionlinejudge.com.br/judge/pt/problems/view/1463 However I get the message 100% error or time limit exceeded, someone could show…
casked 7 years ago Daniel Duplat 31 -
1
votes1
answer66
viewsAfter compiling and running, the algorithm shows "recorded excess floating point", why?
Algorithm to find out if a number is prime, giving the floating point excess error. #include<stdio.h> int main(){ int n, i, divisivel; divisivel =0; printf("Digite um numero para saber se eh…
-
1
votes1
answer1554
viewsDelete repeated words in a string
Given a string, I need to check which are the non-repeated words (or ones that appear only once) and pass those same words to a new string in order to be able to store that information. I tried to…
-
1
votes0
answers47
viewsProblems with input and output in the C language in Visual Studio
Below I have a code simple in C, the problem is that if I leave as is it does not print the received name on the screen, but when I change the scanf_s for scanf it works normally. What would be the…
-
1
votes1
answer362
viewsHow to sort array structures based on the rank of the songs?
The rank of the code ta going in ascending order but the others do not change the positions along with the rank, as I do for the positions of the songs and styles go along with the code ? #include…
-
1
votes1
answer577
viewsHow to make algorithm to calculate efficient (not exponential) recursive Fibonacci sequence?
I’m studying recursion, and I wanted to find a way to make a recursive algorithm for efficient Fibonacci sequence, where the algorithm is not exponential. How will I save the value of subproblems??…
-
1
votes1
answer115
viewsDivision does not generate the expected result
When I do the division of mul / total_filhos_mul the variable mul is zeroed, if I don’t make this division she gets the correct value. What may be happening? #include <stdio.h> int main(){ int…
-
1
votes2
answers117
viewsHow do I make "while" repeat 4 times only and break to the next C command?
int numeros, calculo, soma; numeros = 0; calculo = 0; while (calculo > 0) { printf("Digite o número: "); scanf("%d", &numeros); calculo++; } soma = calculo + soma; printf("A soma entre os…
-
1
votes0
answers58
viewsGlobal vector with variable size - C programming
I’m trying to create a global vector whose size is defined within a function. My code got this way: struct body{ double m; double a; double n; double e; double w; double I; double W; }; struct body…
-
1
votes1
answer68
viewsImprovement and simplification of the Code
I’m in the first semester of college, and as a final project the teacher asked to make a hangman game, I already made my code but wanted to suggest improvements, or report future code problems.…
-
1
votes2
answers214
viewsWhy does the value always return 0?
In the code below the result of the variable valor_1 always is 0. But reversing the order of the variables declaration to unsigned char valor_2, valor_1; the program works correctly. What’s the…
-
1
votes1
answer195
viewsWhy is the "long int" limit equal to the "int`"?
The boundary of type int is 2147483647, but the type limit long int is also 2147483647. Why the limit has not increased?
-
1
votes1
answer51
viewsI don’t understand the following structure
I’m having trouble understanding the following structure: typedef struct TipoItem{ int Chave; } Item; typedef struct TipoCelula *Apontador; //aqui temos um apontador tipo celula. typedef struct…
-
1
votes1
answer32
viewsProgram stops responding when I try to fill the list
This is the code, it simply reads the values and puts it on the list, but in the last loop it stops responding #include<stdio.h> #include<stdlib.h> typedef struct pessoa { int…
-
1
votes1
answer326
views"[Error] expected Expression before 'creature'" in function
The board is a "creature" of my struct: typedef struct{ int status; char classe; int saude; int def; int atc; char elixir; }criatura; No . h: void exibe(criatura tabuleiro[5][10]); // exibe o…
casked 7 years ago Caio Costa 63