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
votes0
answers42
viewsHow to save questoes in an array of pointers
Good night I come here to try to dispel a programming problem that occurs to me. In this solution, I have a file with several questions, and each question can be a matter of one of the 3 following…
-
1
votes2
answers322
viewsWhat does a semicolon mean after an "if"?
I was analyzing a code and came across a semicolon after a if, which means using the semicolon after a if? code: int base_calc(int cb) { if( cb < 30 ) { ; } else if( cb < 20 ) { cb = 30 - 1; }…
-
1
votes1
answer429
viewsDifficulty moving character on board
I have a matrix of structures as a board. My character starts at the position [0][0]: tabuleiro[0][0] = personagem; The character is displayed correctly in its initial position, but I can’t move it…
casked 7 years ago Caio Costa 63 -
1
votes0
answers109
viewsAlgorithm in C to verify that a typed period (start and end date) does not overlap, even partially, with a previously registered period
Galera I am creating a system algorithm and control of hotels in C for a college job , in the reservation module need to make reservations of the rooms between start date end date and when to make…
-
1
votes2
answers75
viewsError in Arduin (pointer to struct)
I’m trying to make the definition of types below but the Arduino accuses error of type declaration. /*Estrutura que abstrai a seringa*/ struct { int pot[7]; float nivel[7] = {0, 0.5, 1, 1.5, 2, 2.5,…
-
1
votes0
answers35
viewsHow does the program give the product of the 2 numbers I put on the console?
This program makes the product 2 numbers ie if I put 3 and 4 the result is 12 if put 4 and 4 is 16. But I don’t understand how does the product through the sum(x+1,y-1) and of sum(x, product(x, y-1)…
-
1
votes0
answers38
viewsC language - cannot acess memory 0x42be0000
I cannot access the memory and bring the Value. The caroname variable also gives the same message. #include <stdio.h> #include <conio.h> #include <time.h> #include <string.h>…
casked 7 years ago Daniel Vasconcelos 49 -
1
votes0
answers61
viewsHow to make a variable define how many times will I have to repeat an entry? C
The first input line contains an integer value N that indicates the various test cases that follow. Each test case contains an integer Amount (1 Amount 15) representing the amount of guinea pigs…
casked 5 years ago Rhuan Candeia 11 -
1
votes0
answers60
viewsError in output file
In an exercise, I need to read an input file as follows: # add # Jabuticaba # Fruto de jabuticabeira. Jabuticabeira. # add # Vacilar # Não estar firme. Cambalear. Oscilar. Tremer. # add # Jacapa #…
-
1
votes2
answers53
viewsRandom number generation in a function is always equal - C
#include<stdio.h> #include <time.h> #include <stdlib.h> int aleatorio(){ srand(time(NULL)); return rand() % 10 + 1; } main(){ int numero1 = aleatorio(); int numero2 = aleatorio();…
casked 4 years, 11 months ago Paulo Sérgio 13 -
1
votes1
answer87
viewsProgram with Recursion in C
I need to make a program that is a game, where the user will input a number and I must determine if it is possible for the user to win the game through a printf saying "Yes" or "No", it is not…
-
1
votes2
answers139
viewsHow to test if the free(); function worked correctly?
I’m creating the abstract kind of 2D Matrix data, and one of the functions I’m doing in TAD is this: int mat2D_free(TMat2D *mat) { free(mat->data); free(mat); } That is, a function to destroy the…
-
1
votes2
answers222
viewsFile In C language
I have a file in this following format: https://mega.nz/#! Dwxxrizk (link to download read file);…
-
1
votes1
answer100
viewsHow to pass structure to function?
An agency in a small town has a maximum of 10,000 clients. Develop an algorithm that can enter each client’s account number, name and balance. The algorithm must print all accounts, their balances…
-
1
votes1
answer117
viewsC - Error reading a character using scanf(): scanf() command is "skipped"
I would like to know why my code does not accept reading characters, simply skip that step and perform the next. float altura, pesoIdeal = 0; char sexo; printf("Informe a sua altura : ");…
-
1
votes1
answer2134
viewsHow do I pass a struct vector by reference parameter?
(1) In the checar_poll function it is not printing the correct values I am reading in the ler_data function, it is printing a lot of numbers and random symbols. (2) If you solve the problem, how can…
-
1
votes1
answer39
viewsError in meter division
Why is my code performing the wrong average division because of the variable contador? int numero,contador, soma; float media; soma = 0; for (contador = 1; contador <= 3; contador++) {…
-
1
votes1
answer143
views"void *Reader(void *i)" What is the equivalent in C++?
I am studying Operating System and I have an exercise to do in C++ and I am with dual (the book brings only in Java), I have to implement a classic problem of reader and writer using semaphores and…
-
1
votes1
answer356
viewsStore random numbers in a variable in C
Hello, I need to compare the random value of 2 dice thrown, and I would like to know how I can store the result of these numbers in the variables D1 and D2. int d1, d2, n; printf("Quantas vezes voce…
casked 4 years, 8 months ago Matheus Santos 41 -
1
votes1
answer110
viewsStore multiple boolean states in only one bool variable
The guy bool so much at C as in C++ consumes at least 1 byte of memory to be stored, I saw that this is because it needs to be addressed or something. So, it would be like this 1 byte to store more…
-
1
votes1
answer2132
viewsHow to pass an file . txt to a function
I would like to create a function that receives a file .txt and do something with it, but I don’t know how to define the sending and receiving parameters, or if I should pass parameter by reference.…
-
1
votes1
answer529
viewshistogram of a c++ phrase
I made the following program to make the histogram of a sentence counting the number of letters and consonants in it but this giving error because I’m trying to get him to print capital letters and…
-
1
votes3
answers282
viewsstrcpy function does not work on Linux
#include <stdio.h> #include <string.h> void envia(char* pdados); int main() { char* link[1000]; strcpy(link,"http://site.com/data.php?dados="); char* dados = "name"; strcat(link,dados);…
-
1
votes1
answer329
viewsHow to allocate a dynamic stack with user-provided size?
I want to allocate a dynamic stack with the size provided by the user, then treat it as a "vector" would be more or less what I did in the function ALOCA? #include <stdio.h> #include…
-
1
votes1
answer650
viewsError reading string with scanf
The logic I already found, but I’m having a hard time reading the string the way the question asks. Only accepts a number when I hit enter, if it does not consider the number a string. Link to the…
casked 6 years, 11 months ago rafael marques 939 -
1
votes1
answer87
viewsC: How to generate a date structure
good afternoon. I’m having a hard time with the C-date manipulation. I’m using the time. h library to mess with dates. I need to create a struct tm which contains the date of the day (example)…
-
1
votes1
answer80
viewsError reading values for a dynamically allocated matrix
Good afternoon, I’m doing some coding to study more about C memory allocation with the malloc function, and I was developing a code to allocate an array and then read values and save it, but it’s…
-
1
votes1
answer51
viewsNo startup error
I’m having a non-boot error, and I can’t figure out why: #include <stdio.h> int main(){ const int LENGTH = 10; const int WIDTH = 5; const char NEWLINE = "\n"; int area; area = LENGHT * WIDTH;…
-
1
votes0
answers31
viewsError when displaying int value
Hello, I’m new to the C language and I’d like to know how to fix this code. When executing the code below, I get the following error message in row 22 and column 13: [Error] invalid Conversion from…
-
1
votes0
answers397
viewsComparison of matrix and vector C/C++
I need to compare a user-inserted op vector with the top 10 columns of each row of a 12x12 array. for(k=0; k<10; k++){ for(i=0; i<12; i++){ for(j=0; j<10; j++){ if(op[k]==d[i][j]){ if(i==1)…
-
1
votes0
answers57
viewsC code only compiles once and then closes
I have a code that I am writing in C, and then a problem is constantly happening. I don’t know if it has anything to do with memory allocation. I have a function: struct elementodos…
-
1
votes1
answer750
viewsRecursive function to calculate the mean
I did that job media() that averages the elements present in a vector of 5 elements. However, the function is returning 2 instead of the correct average. #include <stdio.h> int media(int…
-
1
votes0
answers49
viewsImplementation of an DFA for reading multiple strings
I have to determine if the strings in the file belong to AFD. I was able to do just one string. The goal now is to read more than one string, but I could not do the implementation, always ends up…
-
1
votes1
answer96
viewsWhat is the error in this activity in c
I need the negative values entered by the user not enter the calculation and, still, this negative insertion is canceled by the program. The statement reads as follows:: A city hall did a survey…
-
1
votes2
answers1187
viewsMeaning of two asterisks in function call
I’m trying to understand a code about simply chained list. The function InserirInicio has as a parameter Nodo **inicio, float dado. I could not understand the use of two asterisks in the parameter…
-
1
votes1
answer54
viewsUnderstanding of string delimiter
char *strdelc(char *s, char ch) { int i,j; for(i=j=0; s[i]!='\0';i++) if(s[i]!=ch) s[j++]=s[i]; s[j]='\0'; return s; } This function aims to delete the character sent by the user, but I can’t…
-
1
votes1
answer77
viewsCalculation of survival in C
Researching about calculating a person’s survival days through the days difference I found a program here that served as the basis for this then added the necessary calculations to know the amount…
-
1
votes1
answer26
viewswhen compiling: "Warning: Operation on `eventhead' may be Undefined"
Hello, I’m trying to compile a code with this excerpt: void D_PostEvent (event_t* ev) { events[eventhead] = *ev; eventhead = (++eventhead)&(MAXEVENTS-1); } And I get the following warning:…
casked 4 years, 5 months ago Adilson Enio Pierog 11 -
1
votes1
answer51
viewsHow can I add a variable inside a string using the C language?
In my code, I need to insert within an SQL statement the date formatted as a string using this format: 14/06/2020 - 20h40 But I get the values (minutes, hours, days, months, years) separately (a…
casked 4 years, 5 months ago Breno Xavier 21 -
1
votes1
answer1351
viewsAccessing matrix row and swap row by column
Good afternoon friends, I am trying to make an exchange in an array, exchange the values of the first row with the values of the last column. I know that a row of a matrix in C is a vector. I…
-
1
votes2
answers132
viewsHow to analyze the input in the while condition?
I am learning C, and as the language in which I was "literate" is Python, I usually make associations to better assimilate. In Python, I can receive a direct value in the while condition. Ex.: while…
-
1
votes1
answer706
viewsSocket in C does not compile
I’m having trouble creating a C socket on Ubuntu Linux. I’ve done everything like the guy explains in class and my code doesn’t compile. Code GNU nano 2.5.3 Arquivo: socket.c #include…
-
1
votes1
answer52
viewspointer does not work in visual studio
Personal my question is simple but makes me unable to work with pointers, the variable 'y' simply does not receive the address of x in the example below: #include<stdlib.h> #include…
-
1
votes1
answer189
viewsError comparing characters with strcmp
In the question asks to form a pair of shoes Right and Left so I used strcmp to compare,I used 1 because the strings have to be different,but I did not have the result that the question asked. Link…
casked 6 years, 11 months ago caio portuga 11 -
1
votes1
answer68
viewsWhy am I getting the "0" return regardless of the entered input?
#include <stdio.h> int Comparacao(int x, int y){ int resultado; if(x < y){ resultado = -1; }else{ if(x == y){ resultado = 0; }else{ …
-
1
votes1
answer45
viewsPrint with variable or by direct account?
Are these two methods the same in terms of performance? Is one better than the other or is it better in terms of code organization? Method 01: direct printf("%.4lf\n", sqrt( pow(x2-x1, 2) +…
-
1
votes1
answer200
viewsSave to file . txt (C language)
void gravar_para_ficheiro(struct estrutura2 *lista , struct estrutura *filme) { FILE *fp; int i , index; fp = fopen(listafilmes, "w+"); if (fp != NULL) { fprintf(fp,"Filmes %s\n\n",lista->nomes);…
casked 6 years, 10 months ago Pedro Torres Moreira 13 -
1
votes1
answer56
viewsError with test cases
My teacher recommended this site called Uri, and I’m managing to solve some issues, only that in this tried all the solutions that the question posed and the program that I made out the requested…
-
1
votes1
answer501
viewsWhich code has the highest cost? (Bubblesort in C)
void bubblesort(int *A, int n) { int i, aux; for(i=0; i<n-1; i++){ if(A[i]>A[i+1]){ aux = A[i]; A[i] = A[i+1]; A[i+1] = aux; } } if(n-1>1) bubblesort(A, n-1); } void bubblesortI(int *A, int…
casked 6 years, 10 months ago Hatus Daniel 102 -
1
votes1
answer1186
viewsHow to find a name with struct
I’m making a code that will receive the names of five people and the three gifts that she took to the party, and then it will be asked the name of the person and the gifts that she brought to the…
casked 6 years, 10 months ago rafael marques 939