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
-
3
votes1
answer59
viewsLanguage C - Understanding the Concept of Pointers and Dynamic Allocation, where is the error?
I would like a help in pointer call concepts, and dynamic allocation with struct. I’m developing a code to address an issue of college work, and I’m coming across some errors that I believe are…
casked 3 years, 10 months ago Andre Coelho 31 -
3
votes1
answer57
viewsProblems in deleting all data from an employee
After creating create and read I have been having problems in the update and delete code, but currently I have focused more on delete and I am not able to make it delete the entire employee.…
casked 3 years, 10 months ago Nicolas Sousa 31 -
3
votes1
answer54
viewsconvert input in seconds to days, hours, minutes in seconds from day on another planet. C code
I need to convert the passage of time from another planet to days, hours, minutes and seconds on earth. The point is, I’m getting one int (variable seg) for the seconds spent on Jupiter and I need…
casked 3 years, 4 months ago Pedro Fidelis 33 -
3
votes1
answer77
viewsWhy is it that when I use tabulation on a printf, there are cases where it doesn’t tabulate correctly?
I have this code: #include <stdio.h> void main(){ int fahr, celsius; int inicio, fim, incr; inicio = 0; fim = 300; incr = 20; fahr = inicio; while(fahr <= fim){ celsius = 5 * (fahr-32)/9;…
-
3
votes3
answers40
viewsHow to turn a 2D Array into 2D Pointer in C
It is possible for a function to receive as a parameter a reference to the address of a two-dimensional array (matrix) static, and from the pointer to access the elements of this matrix. In the…
-
2
votes1
answer472
viewsgcc is not found when Makefile is run by Travis-CI
I have a C project on Github and I’m trying to build with Travis-CI, but it always shows the error below: Using worker: worker-linux-9-2.bb.travis-ci.org:travis-linux-2 $ export CC=gcc git.1 $ git…
-
2
votes2
answers183
viewsError while removing stack item
Error of the function pop?? void pop(Pilha *pilha){ if(pilha->size == 0){ puts("pilha vazia"); } else { printf("item removido: %d\n\n", pilha->itens[--pilha->size]);…
-
2
votes2
answers2690
viewsincompatible types when assigning to type 'int *[]' from type 'int'
I created a size vector defined by a constant, and when calling a function that returns me an integer vector, this error is generated: incompatible types when assigning to type 'int *[]' from type…
-
2
votes2
answers156
viewsProblem with Math. h functions
always receive as a result: 0.000000 #include<stdio.h> #include<math.h> int main() { float x1, y1, x2, y2, resultado; printf("insira x1:"); scanf("%f", &x1); printf("insira y1:");…
-
2
votes3
answers694
viewsUsing function and header file (header)
I am making a simple program but using header file . h (header) and a hello world function, but I have the following warning message: Undefined Reference to 'imprime'. I asked someone else to test…
casked 10 years, 7 months ago phpricardo 765 -
2
votes2
answers967
viewsHow to read a random amount of integers in C?
I need to create a way to read integers in the same input, and the amount of integers entered is random every time the program is run. I tried to perform the following algorithm: #include…
casked 10 years, 7 months ago michelvmelo 43 -
2
votes3
answers665
viewsRegister with C File
How to know if there is a Record (struct) saved at any position in a C file ? To the struct: typedef struct Registro { int chave; char caracteres[20]; int idade; int prox; bool contem; } Registro;…
-
2
votes3
answers910
viewsError in fgets function
The program gives Segmentation fault (core dump) when executing the fgets function. Any idea? #include <stdio.h> #include <stdlib.h> #include <string.h> main (int argc, char…
-
2
votes2
answers32709
views"Windows. h" library, what can I do?
I’m starting in C language and would like to know what the "Windows. h" library matches?! it is responsible for what?! what kind of functions it allows me?!
-
2
votes1
answer8101
viewsKnow the line number of a txt file in c
Is there a function or way to find out how many lines a file has without opening it? I need to divide a file into two parts, so that two processes read it at "the same time". I will use the fseek()…
-
2
votes2
answers3403
viewsCPF data in a C Struct
Hello. I’m having a problem reading data from a CPF. I tried using int, long int or even a char vector[12]. With char I can keep the CPF’s that contain '0' at the beginning, and with int or long int…
-
2
votes4
answers5957
viewsError in code, C
I created an extremely simple code just to test the Code::Blocks, but no matter what I do, always returns the following error: collect2.exe: error: ld returned 1 exit status I still don’t understand…
-
2
votes2
answers306
viewsDoubt in Struct + Pointer in C
Considering the code below, I wonder why the second printf of the Lealuno procedure does not print correctly? #define MAX 3 typedef struct aluno{ int matricula; float notas[2]; } Aluno ; int t=1;…
-
2
votes1
answer1116
viewsHow to read a line in C
How to read a row of integers and store in a dynamically sized array ? Currently I read the line as string(although the input is only integers) using gets, only way it worked. The code is like this:…
-
2
votes2
answers159
viewsHow to control the flow when an invalid value is entered?
In case I want a condition to repeat several times and several times I have to use the command return for any specific line? I will put the program to explain better: #include <stdio.h>…
casked 10 years, 5 months ago Leonardo V. De Gasperin 713 -
2
votes1
answer377
viewsIs it only possible to write code with bugs or vulnerabilities in C?
Anyone who is programmer and experienced knows an implicit truth: C is practically the language of the gods. C corresponds to at least 98% of the software that runs on all computers and thanks to…
-
2
votes1
answer668
viewsAutomatic input generator
I am developing Dijkstra’s minimum path calculation algorithm using the C language, I am doing several solutions to the same problem and then testing which is the most efficient. For this I needed…
-
2
votes1
answer205
viewsConvert struct with nested struct to record
I have a little "hindrance" in a project I’m working on. We received a DLL written in C, in order to communicate with readers of this company. In attachment came an example written in Borland C++ 6,…
-
2
votes2
answers517
viewsProblem loading file to memory
I am trying to load several files into memory (small file), but the problem is that when I try to load another file soon after, all the files get the same name as the last uploaded file. I am using…
-
2
votes1
answer80
viewsComputer clock
Is it possible to calculate the difference between two time records separated by less than one second using the computer clock? For example, between 12h00m00s000ms and 12h00m00s050ms.
-
2
votes2
answers52
viewsYou’re not stopping file processing
Why aren’t you stopping the comparison? /*7. Faça um programa que leia uma sequência de nomes no formato “nome sobrenome” e armazene-os em um arquivo texto. A lista de nomes termina com um nome…
-
2
votes2
answers4833
viewsHow to receive a char pointer via keyboard in C/C++?
How do I receive a pointer from char keyboard?
-
2
votes2
answers160
viewsWhat is the difference between open and opendir calls on UNIX?
If the open file uses the open system call, why is there another system call to open files directory (opendir), if a directory is a file type? It wasn’t supposed to be a call just for all kinds of…
-
2
votes1
answer725
viewsIs using %(limit)[ n] in scanf safe to capture strings?
I would like to know a totally safe way to capture strings without running the risk of buffer overflow or any other threat. I read a lot about ready-made functions and would like to know which ones…
-
2
votes1
answer846
viewsHow to extend the storage capacity of char variables
hello! I am having problems with a "mini dictionary" that I am mounting.... It is basically ready, but the definition of words, because they are too long, present an error when they are displayed. I…
casked 10 years, 2 months ago Luis França 55 -
2
votes0
answers129
viewsPointers to Functions
I’m facing a small problem with function pointers in a program for Microchip Pic Series 18 microcontrollers. The code displays the prototypes of two functions involved in the problem and a call to…
-
2
votes3
answers476
viewsHow to see the implementation of a function?
From time to time I have some doubts about the efficiency of a code and I think that if I see the implementation of a function I am using I can know how efficient it is or not. Some examples of…
casked 10 years, 2 months ago ViniciusArruda 549 -
2
votes1
answer691
viewsGet titles from open windows
I have a C++ program that arrives in a certain part that I need to check if a window is open, if it runs a part of the code. How could I take the windows open and do this check? I found a link that…
-
2
votes1
answer1393
viewsVector struct and pointers
I have to pick up data (name and phone) of some people in a struct, then store them in an array, all this for a function/procedure. At the time of printing comes out some strange characters. I’m…
-
2
votes1
answer48
viewsSelect notes to be printed
I need to print only the notes above >=6, in which place of the code I put the if or some other instruction? I tried and I couldn’t find the right place. #include <iostream> #include…
-
2
votes3
answers133
viewsMarathon Problem: Calculator (Level 2)
This problem seems very simple, however my code does not commit in any way by error with some random input. The program that manages the submission of the question gives me some tips: Check the…
-
2
votes2
answers431
viewsHelp to determine vector/matrix size - C language
What I’d like to do is put into a vector or matrix, information from a file txt no prior knowledge of the number of "inputs" to know the size of the vector or matrix. With the size of the vector or…
-
2
votes2
answers7557
viewsHow to Save Read Chained List in File?
I’m a beginner in programming and I’m coding this program for a college job. It is a "pizzeria manager", I need to save read a linked list (customer registration) in a file, so that the data is not…
-
2
votes1
answer453
viewsWhat does the error mean: realloc(): invalid Pointer: 0xb78094d8?
My program, whose code is further down, has shown the following error: I don’t understand because I have too much memory on my PC, and all the compiler sites have the same problem. *** Error in…
-
2
votes2
answers503
viewsWhat is the error in this Code:
I’m trying to compile this code,do use head C but it’s returning me errors #include <stdio.h> void go_south_east(int* lat, int* lon) { *lat = *lat -1; *lon = *lon - 1; } int main() { int…
-
2
votes1
answer909
viewsHow does buffer work using printf and scanf?
Using the printf, when I do: printf("\n\tQualquer coisa\n"); It inserts this first into a buffer and then prints to the screen (standard output) ? Using the scanf format %c, it captures from buffer…
-
2
votes1
answer99
viewsWhen including a header file, does the compiler include all functions in the final program or only the functions used?
That is, the executable will have the entire library in it or only the functions I use will be included by the compiler ? With this, including many libraries can make the program heavy (taking up…
-
2
votes1
answer921
viewsError while printing chained list
Hello, I have an error in the function that prints a chained list. I think the error is in the print function’s for, but I may also be saving the address of prox wrongly. Follows the code: /* *…
-
2
votes2
answers4172
viewsRead comma-separated file data in C
I need to read the data of an entry in the format: 100,Refrigerator,180,90,89,1200.00,4,white After some researches, I found the Strtok function that separates the data between commas, and the code…
-
2
votes2
answers3451
viewsRead a comma separated string
My reading has been established to the comma, but he’s reading the whole field to the end of the line when reading the string. The code is read correctly, but only in the code. #include…
-
2
votes1
answer835
viewsHow to capture hardware id
I’m trying to find a way to capture the serial of the hard drive, CPU and motherboard, the CPU I found a mode that is using cpuid. h, now the motherboard and the hard drive I found no way to…
casked 9 years, 7 months ago carolzinha 171 -
2
votes1
answer218
viewsError comparing two strings
I’m trying to compare two strings, when I enter a name in my chained list it cannot be entered if it already exists. I have used the function searchname to display a searched name and to delete, but…
-
2
votes1
answer609
viewsC socket - Client-server connection test (Linux)
I’m working with sockets in embedded system communication. I create a thread to handle the connection, but as my system uses Wi-Fi connection I need to perform some way a connection test before…
-
2
votes1
answer84
viewsStoring a character array within a heap memory
I would like to know how to order a set of characters in a vector, and store them in memory heap.
-
2
votes2
answers394
viewsFunction giving wrong values
For some reason, my function of calculating distances is sometimes giving wrong values. Not only that, but the values seem to be from memory addresses (because they are very large), but I’m not sure…
casked 9 years, 11 months ago user3741052 87