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
-
5
votes2
answers295
viewsWhy did a dynamic array work without the use of malloc()?
Follow the code passage below: int main(void) { int tam, vet[tam]; printf("\ndigite tam: "); scanf("%d", &tam); return 0; } I didn’t know this worked, because I’m typing the vector size at…
-
5
votes1
answer130
viewsTime is early in program . C
I have an application in .c, I finished it but I have a problem with the time. Example: I am recording everything that is done with date and time only the time is early. When I do an operation at…
-
5
votes3
answers10734
viewsRecursion to return numbers from 0 to n
I’m trying to make a recursive function that returns the n numbers of 0 until n, my code went like this: #include <stdio.h> int imprimenumeros(int n){ if (n==1) return 1; else return…
-
5
votes2
answers2276
viewsMethods without parameters and with parameters
Declaration methods without parameters: void exemploDeMetodo(){ int i; } Calling methods without parameters: exemploDeMetodo(); If I want to make a method with parameters it’s like? That’s the way…
-
5
votes3
answers937
viewsOperators, order, relevance, how it is read and priority
I came across the following question in a comment from the following Question One more question. The != operator is the same thing as < ? So I decided to come up with an answer by explaining it…
-
5
votes3
answers540
viewsColo allocate a memory based on the size the user typed
How can I get it right after the user enters a string the program counts the number x of characters of this and allocate X bytes to it? I am not able to do it, I tried for example to make after the…
-
5
votes1
answer20517
viewsCompare two strings in C
Hello, people, I want to compare two strings but the result is not returning what is expected, in this case the index in the function search_name, the error is in the fourth line of the function…
-
5
votes2
answers699
viewsHow to send a SOAP in C?
How do I send a C SOAP? I have a Web Service that consumes SOAP and have to send that SOAP in C. How can I do that? Is there an API or I have to create a library?
-
5
votes1
answer518
viewsSending characters through the serial port including zero-value bytes
I am making an application in which I need to send a character array via serial to an external hardware (declared as unsigned char) containing commands and times. With the commands I have no…
-
5
votes1
answer170
viewsHow is the Linux kernel or programs written in C tested?
When we use Java, we use Junit to test codes. But codes written in C, such as kernel Linux, how it is tested?
-
5
votes3
answers389
viewsCompiler error when trying to reset vector
Compilers error when I try to reset an array with the command vetor[10] = {0}; And he only makes a mistake in that line because I also used it in the assignment int vetor[10] = {0} and there does…
-
5
votes3
answers185
viewsProblem with program that prints three numbers increasingly
I’m having trouble creating the decision structures in a program that reads three numbers and prints them increasingly. My code that’s going wrong is this:: #include <stdio.h> int main (void)…
-
5
votes1
answer332
viewsProblems with dynamic allocation
In an exercise I need to make a record of a struct possibly declared as follows:. typedef struct Locatarios { char nomeLocatario[MAX_NOME]; int codigoLoc; float valorAluguel; } Locatarios; It is…
-
5
votes2
answers2880
viewsHow can I print only the fractional part of the number
Good evening, I would like to know how I can print the fractional part of the real number, that is, when I type 5.678, I would like to print in the second A(where this comment), only the number…
casked 9 years, 7 months ago Gabriel Vinicius 339 -
5
votes1
answer31551
viewsPass matrix as function parameter?
I’m studying Dijkstra’s algorithm and I haven’t tried using adjacency lists yet. I knew I could solve the problem with a matrix, but the fact is that I can not receive the matrix in the function. If…
-
5
votes3
answers557
viewsUnsigned int doesn’t work?
Next, my program keeps compiling even after I have assigned a negative value to an unsigned variable, why does this happen? I use IDE Code::Blocks 13.12 unsigned int numero1 = -1;…
-
5
votes2
answers15519
viewsIndefinite reference of functions
I have a problem related to modularization of my project. Do not pay too much attention to the logic of the program, because the biggest problem I face is the fact that the program does not compile.…
-
5
votes2
answers518
viewsData Structure - C Double Chained List
I’m doing an activity proposed by a teacher, who asks to remove an element from the end of a double chained list. Except the function I set up to solve the problem is locking the program. In the…
-
5
votes2
answers912
viewsHow to free memory from an internal malloc to a function that returns a pointer?
How to release a malloc internal to a function that returns a pointer? In a simple way to try to exemplify my doubt, consider the following function f: int *f(int tam) { int *ptr = malloc(tam *…
-
5
votes1
answer179
viewsSegmentation fault: branch and bound in c
I have a persistent error in my code. My goal is to find the way in a maze mounted on an array with an algorithm like branch and bound. Follows the code: FILE *ent; FILE *saida; int NL; int temp;…
-
5
votes4
answers199
viewsProblem accessing array element
I have a problem in the function below that truncates all words to have at most N characters. For example: if the string "freedom, equality and fraternity" means the invocation of truncW(t,4) should…
-
5
votes1
answer1562
viewsHow to make a wrong user input not bug the program?
Example, I declared the menu option as int, then the ear bug goes in there and type in a letter or a special character and this will make the program crash. The question is: is there any way to…
-
5
votes0
answers183
viewsState machine that locates the first line breaks, in C
How to make a state machine in C, using decision commands (if, else) to go through a buffer received from the internet, byte by byte, in order to locate the first line breaks (\n\n), and only then…
-
5
votes3
answers557
viewsConvert "unsigned int" to "unsigned char" vector?
I need to convert a unsigned int in a vector of unsigned char to later translate this address into binary, for a work that needs to simulate a virtual memory. Can someone explain to me how to do…
-
5
votes2
answers1314
viewsConfigure the compiler output path in Netbeans
Would anyone know how to configure in Netbeans, so that when I compile a project, it manages the executable in a given folder? In the project properties, you have the binding option, which I believe…
-
5
votes2
answers661
viewsWhere to create macros in C?
In terms of good programming practices, if I want to create a macro, for example, a macro that has about 30 lines of code, I should implement it in the archive .c or in the .h? What is good…
-
5
votes1
answer137
viewsHow to use build options in Ideone?
Yesterday in answering this question wanted to test it on Ideone, while running the code I received this error: Prog. c: In Function 'main': Prog. c:12:9: error: 'for' loop initial declarations are…
-
5
votes1
answer139
viewsPrecedence of operators with pointers
Having, for example, the following instructions: int i=10, j=20; int *pti, *ptj; pti = &i; ptj = &j; What is the meaning of j = pti == ptj; and of i = pti || ptj; ? Also, I read that the sum…
-
5
votes3
answers396
viewsDoubt: dynamic list chained inside another, in C
I’m having a huge difficulty to be able to create a dynamically chained list within another using data structure and manipulation, because I haven’t found anything that exemplifies how to create a…
-
5
votes1
answer819
viewsHow does "printf()" work?
How the code works behind the function printf() do C? I am aware of what this function does, I want to know how it does.
-
5
votes4
answers456
viewsMemory allocation for pointers
I’ve been reading and studying on pointers and came across the following quote in a book: "Although it is possible to use them as vectors, pointers do not have their own memory. You can only use…
-
5
votes2
answers7902
viewsHow to define the vector size dynamically in C?
In language C I can define a vector specifying the size for example int vet[3]; how can I set the size of vector dynamically, for example by asking the user to inform the size of the vector ?…
-
5
votes1
answer169
viewsSpecial treatment for string, why?
I know arrays are static elements used when you have a predetermined size that you can use. But speaking of initialization, when the size is already set next to the array, I would like to know,…
-
5
votes3
answers18598
viewsHow to find the rest of the division?
I’m studying a workbook I found on the net, she asks for an exercise but did not teach to do it in the previous pages, I tried and it did not work, I thank you for your help. Make a program that…
-
5
votes3
answers1118
viewsKey capture
I’m developing a C-language cover game (gcc 4.9.2) to the Ubuntu terminal 15.04. I need to capture a key typed by the user so that he can change the direction in which the topsail anda (wupward, s…
-
5
votes1
answer59
viewsDoubt cast with pointer
while( ++idx <= fp_size) { byte current = buff[idx]; int integer = 0 ; short shortint = 0 ; if(idx < fp_size - 3) integer = *((int *))&buff[idx]; } What kind of cast is this *((int *))?…
-
5
votes1
answer324
viewsAlgorithm Complexity Analysis
A professor at my college passed an exercise to analyze the temporal complexity of this algorithm, but I’m not getting it at all. Someone knows how to give me a light on how to separate the…
-
5
votes1
answer227
viewsProgram does not execute anything when it enters function
My program runs, but right after asking for the value prob() the .exe stop working. I thought it was some communication problem between functions on account of the matrix lattice[][4] as an…
-
5
votes2
answers7523
viewsconio. h library in C language for Ubuntu
I’m programming in C on Ubuntu’s Codeblock. I am trying to add a library conio.h. During several researches I found a site that for the sake of incompatibility in Ubuntu with the conio library. h, a…
-
5
votes2
answers540
viewsHow do I exit a loop by typing a specific value?
I need to make a program that multiplies the numbers informed by the user, and when it reports 0 (zero), the program shows the multiplication of the numbers typed. However, I am in doubt of how I…
-
5
votes3
answers6933
viewsRotate matrix by 90º
I need to create a C algorithm to rotate a 10x10 matrix by 90 degrees, however I cannot use an auxiliary matrix for this. Simplifying what was asked to try to find some pattern and use it to solve…
-
5
votes2
answers2741
viewsHow to identify a specific number in any numerical value?
For example, my variable valor (whole type) has the value 1354, note that the number 13 appears at this numeric value. How can I identify a specific number at any other numeric value? I’d like an…
-
5
votes2
answers1634
viewsWhy are you making a mistake when trying to compile the program with this library (IUP)?
By including a C library you are giving this error when trying to compile ||=== Build: Release in iup (compiler: GNU GCC Compiler) ===| obj\Release\main.o:main.cpp|| multiple definition of…
-
5
votes1
answer2438
viewsA break within two for actually works as a continue?
If I happen to have one break within two for, as in the example below: for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { break; } { The break won’t make the show come out of both for,…
-
5
votes1
answer1901
viewsHow to use realloc() dynamically in struct allocation?
I have a structure struct TMedidorEletrico *medidor;, and it is necessary to reallocate the memory to this structure dynamically, until the user closes the loop. Memory must be reallocated one step…
-
5
votes2
answers606
viewsDetermine specific size for console in C
It is possible to set a specific size for the codeblock console (In C language) to open when I run the program? I need it to open at a certain size because I won’t use the whole screen. I saw…
-
5
votes1
answer605
viewsClose loop when typing specific character
Hello! I need to resolve the following question, but I’m not getting it. Write an algorithm that calculates the average arithmetic of the students' 3 grades (number undetermined of pupils) of a…
-
5
votes3
answers108
viewsIs there any way in pure C to implement set?
I’m doing a job for college and I need to check word for word from a "dictionary" on file txt and compare these words to the words of an array that has been provided. To make my life easier (because…
-
5
votes3
answers5080
viewsClear C buffer with fflush() or __fpurge()
Studying strings in C I came across the following phrase: "Clearing the buffer, for example, is not always desirable, and for more professional and secure programming it is not recommended to use…
-
5
votes2
answers12681
viewsHow to resolve accentuation problems when using the setlocale function?
I am trying to define the language of the program to Portuguese, using the setlocale(LC_ALL,"Portuguese"), however, much of the program was done on Ubuntu. When the other programmer sent me the…