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
-
2
votes1
answer708
viewsHow to convert percentages to C?
I tried to make a program to convert percentages from days to weeks, months, year, etc. However it is not working, this is the code as it is now, I do not know what the error is. #include…
casked 8 years, 11 months ago Ricardo Mantovanello 21 -
2
votes1
answer646
viewscomparison using characters in c
Okay, the problem is only in function q31 and q311. http://pastebin.com/8CJwKej4 I left the complete code on the link above. then here is this function q311: void q311(){ char forma; int…
-
2
votes2
answers208
viewsProblem with threaded list pointer offset
I’ve had a problem with the shift of pointers in my code for a few days now. I try to make that if the point of my object on the screen is greater than a value, offset this object from memory, but…
-
2
votes1
answer202
views -
2
votes1
answer148
viewsDoubt typedef void*
You guys, I’m watching the next show: typedef void* type_t; so I was doing some tests and I put type_t in a sizeof and it returned me 4 bytes more size as well ?…
-
2
votes1
answer186
viewsProgram compiles but stops responding during execution
I wrote a program that compiles, but is stopping responding during execution. This program opens a PGM file and saves the derivative by convolution in saida.pgm. The function LerPGM() receives a…
casked 9 years, 1 month ago Eduardo Moura Tavares 23 -
2
votes2
answers10186
viewsHow to order a chained list in alphabetical order?
I have to make a program that creates a chained list containing structs with information from a participant(name, Cpf...). I have already inserted the function and I want to sort the chained list in…
-
2
votes1
answer19917
viewsHow to read text files and put words into an array?
I need to make a code that reads a text file (txt) and save only the words at the positions of a vetor, below follows my code: int main(int argc, char** argv) { FILE *file; file =…
-
2
votes0
answers60
viewsLinux Sockets - Doubt
Why use these functions with socket implementations and what they serve? select() FD_SET() FD_CLR() FD_ZERO()
-
2
votes1
answer53
viewsClient http socket in c
People would like someone to explain to me the following code snippet of an http client does, mainly this expression on while(sent < strlen(get)), the complete code is found at this link. int…
-
2
votes1
answer1247
viewsC program for solving mathematical expressions using binary tree
I’m trying to build a tree that receives a completely parented mathematical expression [e.g.: ((a+b)+c)] but I think my insertion function is wrong! Will someone give me a light? typedef struct…
-
2
votes2
answers3240
viewsHow to take information from one function and use it in another?
I need a program that performs sum and multiplication according to the user’s choice and later select the corresponding function that will read the values, until the user enters 0 and the program…
-
2
votes1
answer38
viewsHow to have an option that exits the program or continues running with others?
You can add a third option when asking the user, and this option will only appear after the first calculation. Ex. (3 quit). I just thought of the way the 3 options emerge from the beginning.…
-
2
votes3
answers82
viewsShould I allocate the member of the date structure as well?
Assuming the following structure: typedef struct lnode{ struct lnode *next; void *data; int id; }Lnode; Let’s say I want to keep one Lnode in the heap: Lnode *exp = malloc(sizeof(*exp)); I must now…
-
2
votes1
answer153
viewsRemoval item in chained list C
Guys I’m having a very annoying little problem, I’m implementing a simple A* . When I move the already checked item to the closed list and move the item from the open list, it is giving undeclared…
-
2
votes1
answer571
viewsPut and take whole file?
I have two whole variables a rp and rc, and I have to record them in a file as a way to save their value, and then take them and put them into variables like inteiro to use in my program. To write…
-
2
votes1
answer12084
viewsRandom letters: How to generate with Rand and how to compare them in C
I’m trying to create a char vector of 10 positions, I want to feed it with 10 random letters and sort down with Bubble Sort. My question is: does Rand generate random characters as well as generate…
-
2
votes1
answer2933
viewsHow to find the number of rows and columns of a dynamically created matrix?
Based on my knowledge, I created a function that returns an initialized matrix: int** initMatriz(int rows, int cols){ int i,j; int** matriz; //aloca memoria para todas as linhas matriz = (int**)…
-
2
votes1
answer49
viewsKeeping names
I want to allocate a string within any structure that I can search for these strings after. I need to enter a condition to end the name insertion. I’m thinking of a structure that runs until the end…
-
2
votes1
answer742
viewsParser misidentifying tokens (Flex and Bison)
I am implementing a compiler based on the Tiger language proposed by Andrew Appel’s book "Modern Compiler Implementation in C". Link: https://www.cs.princeton.edu/~Appel/Modern/c/project.html I’m…
-
2
votes1
answer121
viewsMark unused positions on a vector
We assume that, in a given implementation, the positions of a vector may contain values of -2^16 to 2^16. You need to "mark" unused positions (for example, put a * ). However, given the range of…
-
2
votes1
answer758
viewsProblem with menu + buttons + lcd
Hello. I’m having trouble making a program in C language with buttons, lcd (16x2) and a PIC18F4550. Below, I put the description of the program and the code I have so far, a keyboard filter and some…
-
2
votes1
answer135
viewsError in programme C (determinant calculation)
#include <stdio.h> #include <math.h> void zerar(int n,int m[][n]) { int i, j; for (i=0; i<n; i++) { for (j=0; j<n; j++) { m[i][j] = 0; } } } void printm(int n, int matriz[][n]) {…
-
2
votes2
answers539
viewsHow to include the headings of the gotoxy() and textcolor() functions
Which library could be used to compile a C code that uses the functions gotoxy() and textcolor(), by Code::Blocks 16.1, Windows 7 environment? I’m using: stdio.h, conio.h, windows.h and stdlib.h but…
-
2
votes1
answer244
viewsGenerate executables with names other than "a. exe" by Sublime Text
I am using the Sublime Text to write the codes and leave them on the desktop Every time I save a file .c, it generates an executable for Windows. When saving more than one code .c on the desktop and…
-
2
votes0
answers54
viewsDifference of char *str and char str[] parameter in function?
What is the difference in using this function void removeSpaces(char *str) and void removeSpaces(char str[])
-
2
votes1
answer1491
viewsRecursive function to remove from a headless chained list
I was looking for the minimum first to then remove it. Someone helps? /*Escreva uma função recursiva para remover de uma lista encadeada sem cabeça uma célula que contêm um valor mínimo.*/ #include…
casked 9 years ago Matheus Francisco 650 -
2
votes3
answers3377
viewsHow to eliminate excess spaces in a string?
C code to remove strings spaces is not working. It stops at execution. #include <stdio.h> #include <stdlib.h> #include <string.h> void removerSpacos(char str[]) { int i, j; int tam…
-
2
votes1
answer3661
viewsReading and Comparing C File Login and Password
I am programming my system login screen with the help of files, ie save/read the data within a arquivo.txt. So far I was able to register the login and password of the user, but I am dealing with…
casked 9 years ago Marcielli Oliveira 1,597 -
2
votes1
answer224
viewsStore some elements of a struct array in another struct array
I have defined a struct array struct CAMPO campo[2] in which it will be pointed out by a pointer struct CAMPO *ptr_campo and that pointer will be aimed at the players inserted in the field, here is…
casked 9 years ago Renata P Souza 333 -
2
votes1
answer102
viewsthe result obtained does not correspond to the actual result
I’m struggling and I don’t even know how to explain, excuse me for the title of doubt, here is the code defined... #include <stdio.h> #include <stdlib.h> #include <string.h>…
casked 9 years ago Renata P Souza 333 -
2
votes2
answers282
viewsI can’t divide with a vector element
I made a code to simulate the Monty Hall paradox, so that I can simulate 1000 times the results and write the statistics. However, I cannot divide an element of an int array by an int, every time I…
-
2
votes1
answer364
viewsHow to know if three points are clockwise or not in C/C++?
Given three points P1, P2 and P3, what is the best way to know whether this order is clockwise, counterclockwise, or neither (the three are collinear)? For example, in the image below the dots are…
-
2
votes2
answers324
viewsHow to declare a component of a static struct in the function? C
In the file . h: struct conectores { int entrada[n]; int busca[n]; } conect; struct connectors conect; void cadastra_entrada(FILE *fp, int cont, struct conectores conect, int entrada[n]); Function:…
-
2
votes1
answer445
viewsCalculation of the volume of an irregular plot of land
The code consists of calculating the volume of an uneven surface where I am using a matrix 2 x 2 of maximum size 1000 x 1000, which represents a rectangle, so the maximum area of the land is…
casked 8 years, 11 months ago Alan Nascimento 113 -
2
votes1
answer3931
viewsVector file content in C
I need to read a text file and store each word of the file in a vector position. The reading was done normally and the file was passed by parameter such as the amount of words. The code performs the…
-
2
votes0
answers48
viewsVirtual memory using bitset algorithms
I’m seeing the following macros that take as parameters how many frames (virtual memory) ram memory may have, but I can’t understand its meaning: define INDEX_FROM_BIT(a) (a/(8*4)) define…
-
2
votes1
answer246
viewsProblem to assign more than one value to variable
#include <stdio.h> int main(){ int d; int e; int peca1; printf("digite um lado da peca: "); scanf("%i", &d); printf("digite outro lado da peca: "); scanf("%i", &e); peca1 = d , e…
-
2
votes1
answer1889
viewsBreak line when typing entries
I have a vector of structs with 10 people and I want my registration function to receive only one person at a time. In the terminal, the register of the first person is made correctly but then I get…
-
2
votes0
answers162
viewsLogic of developing a virtual keyboard in c
I create a array containing the 127 characters ascii eg list(char(0, 1, 2, 3, 4, ...)) and add an identifier with each key with each item in the list - corresponding to their respective values. I…
-
2
votes1
answer104
viewsProblems with uint64_t in C++
I have a problem with very large numbers. When I put the input 64 my program does not display the right answer, remembering that all smaller numbers are with normal output. Exit from the program: 0…
-
2
votes1
answer142
viewsAccessing variables dynamically in C language
I understand that it is possible to access variables dynamically in Javasscript, but to do this in C, I can’t find anywhere. Follow the code in Javascript: var n1,n2,n3,n4,n5; n1 = n2 = n3 = n4 = n5…
-
2
votes1
answer102
views -
2
votes2
answers1420
viewsRead numbers separated by commas
I need the sixth figure printed on a arquivo.txt. I tried to read the file and print the first six on the screen to see if it was working, then generate a file with only the value I need organized,…
-
2
votes0
answers187
viewsDoubt about the GTK+ graphic library (Drawing a Tree B in the C language)
Good afternoon, Recently I had a job that was basically the implementation in C Language with graphical interface of a B-Tree, the program should allow and show the insertion, removal and search…
-
2
votes1
answer670
viewsPrinting extended ASCII in C
Look at this simple code written in C: unsigned char *palavra = "fantástica"; int tamanho = strlen(palavra); int i; for (i = 0; i < tamanho; i++) printf("%i ", palavra[i]); printf("\n"); Output…
-
2
votes2
answers525
viewsError with sem_init() function on Linux
I’m trying to solve a problem with semáforos, but when I try to use the function sem_init() I get an error saying there’s an indefinite reference, can tell me why? I have the library of semáforos…
-
2
votes1
answer8293
viewsC registration system saving in file
Here is my code. I believe that the procedures of receiving strings, receiving information and entering into the global vector are working, but the program stops working when selecting the list…
casked 8 years, 5 months ago Vinícius Valentim 29 -
2
votes1
answer66
viewsWhat are the differences between BUILD_STATIC_LIBRARY and BUILD_SHARED_LIBRARY?
In trying to compile, I came across these two options, in my case only one worked, which led me to the questions: What one could have, that the other doesn’t have? What advantage, and disadvantage…
-
2
votes1
answer215
viewsDefine an array and the type of a function in C
Hello, I am developing a C language boot project, namely the creation of a Multimedia Management System that will have to be able to manage a database of discographic articles such as Cds, Dvds and…