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
-
16
votes3
answers9258
viewsWhat good is while(0) and while(1) in C?
What is the purpose of this? While(0) or While(1). Does 1 verify that it is correct and 0 that is wrong? Why?
-
16
votes2
answers2560
viewsFork in Windows
There is something in Windows like (or some alternative similar to) fork of the POSIX (UNIX and Mac) systems to create a child process that is an exact copy of the parent and runs from the call…
-
16
votes1
answer677
viewsWhat is undefined behavior, unspecified and defined by implementation?
What is the difference between the three terms "undefined behavior", "unspecified behavior" and "behavior defined by implementation"? Why do they exist in these forms?
-
15
votes4
answers309
viewsHow to deal with a comet process?
Analyzing the linux API I noticed that an interesting structure is possible: #include <unistd.h> #include <stdlib.h> int main() { while (1) { if (fork()) exit(0); // Altera meu pid…
-
15
votes3
answers8488
viewsWhat happens in a conversion from a char to an int?
How it works when you take a variable and do char-48 To transform in integer, as for example in this code I made, I used a date for example "22/05/1994" stored in a char vector and transformed in…
-
15
votes4
answers6237
viewsHow does the "#include" directive work?
C++ "include" does what exactly? I know it "matters" a header/library. But if I have a Header. h com: #include <string> using namespace std; string a() { return "PTSO"; } and on Main.cpp:…
-
15
votes3
answers2478
viewsHow do C graphic libraries work?
How graphic libraries work? For example, the standard C execution mode is the application console, as from that only text can create the graphical libraries where you understand pixel instead of…
-
15
votes2
answers6497
viewsWhat is pointer to pointer?
How to use it pointer to pointer? I find it hard to tell what it is memory address and memory value when I try to use pointer to pointer, it seems mysterious to me. Someone could give me an…
-
15
votes1
answer736
viewsC programming using GTK
I have to make a game like college work (Scrabble). The problem is this. When the event_box of the atrial player is pressed call a callback function, so that the image that is in the event_box…
-
15
votes2
answers1239
viewsWhat is the difference between *var++ and *var += 1?
I’m writing a feature with the signature: int increment(int *val). My intention is to receive an entire pointer, increase its value in 1 and return that value. The body of my function was as…
-
15
votes1
answer311
viewsHow does the switch work behind the scenes?
Seeing those comments on the use of switch is the doubt how it really works and why it is different from the if when only buy for the equality of a single variable against a sequence of values. How…
-
14
votes3
answers29291
viewsCreating your own header file
Someone could explain to me the utility and how to create the header file in c with an example?
casked 10 years, 10 months ago Nicolas Bontempo 1,652 -
14
votes2
answers23232
views -
14
votes2
answers4380
viewsLinux C programming - IDE vs. editor + command line
I’ve been looking for a similar question here and I haven’t found anything so if you’ve already answered I’m sorry. I’m a beginner in C programming and would like to know if it is more appropriate…
-
14
votes1
answer5442
viewsWhat is big-endian and what is the difference to little-endian?
I have a basic notion of what the big-endian and the little-endian are, but I cannot see exactly how the different form of storage can complicate portability. What portability problem occurs due to…
-
14
votes1
answer37459
viewsWhat is the meaning of the word "Cout" in C/C++?
Well, it is very common in programming languages to have responsible keywords for printing data output. Some are classic like echo, print, printf and write, etc.. But in the C/C++ we have the cout.…
-
14
votes5
answers13398
views -
14
votes2
answers2762
viewsWhat is the purpose of the void parameter in functions in the C language?
The parameter void it’s just semantic or he does something I don’t know? int main() { return 0; } int main(void) { return 0; }
-
14
votes2
answers2384
viewschar[] or *char malloc?
What difference in C between char text[10] or char *char = (char *)malloc(10*sizeof(char)); What advantage of using malloc on a pointer?…
-
14
votes2
answers2381
viewsWhat is the difference between static and dynamic linkage?
Recently, searching why small Go codes have a much larger executable than the same C-generated code, I read an answer stating that the reason is because Go use linkage static, unlike C, which uses…
-
14
votes4
answers1231
viewsVery interesting switch/case on Swift - What other languages support this?
The Swift language presents a very interesting and very intuitive way to work with intervals using switch-case, with "partial matching" techniques, "Pattern-matching" etc, look at these examples:…
-
14
votes1
answer1573
viewsWhy do the arrays index and other sequences start at zero?
Why the array does not start with 1? There is some technical reason to have adopted 0?
c array characteristic-language mathematics computer-scienceasked 7 years, 9 months ago Maniero 444,682 -
14
votes1
answer615
viewsHow does the lifespan of static variables work?
I just saw a question about C. In it the following code was shown: #include <stdio.h> int main() { static int a = 5; printf("%d", a--); if(a) main(); return 0; } Example running on repl.it.…
-
14
votes2
answers128
viewsWhat are they and when to use Anonymous Unions?
During the data structure book reading, it was briefly presented the concept of anonymous unions, which would be the definition of a union without specifying a label (name). However, I did not…
-
13
votes3
answers949
viewsHow does the Xor Swap algorithm work?
I was studying bit-by-bit operations and came across the Xor Swap algorithm. I understand what it does (exchange the value of two variables), but I don’t understand how it does it, at the level of…
-
13
votes2
answers2414
views#pragma Once or #ifndef?
I know there are two ways to prevent a header file from being duplicated in C C++: #ifndef FOO_H_INCLUDED #define FOO_H_INCLUDED class Foo { // código }; #endif And #pragma once class Foo { //…
-
13
votes6
answers35893
viewsKeyboard buffer cleaning after scanf
I’m having trouble with the job scanf();. When reading two or more values, the later values are not read. I’ve already tried: __fpurge(stdin); After reading, but in this case I need to enter after…
-
13
votes2
answers7627
viewsWhat is the C/C++ volatile modifier for?
I’ve seen in some codes on C/C++ statements like this: volatile int i = 0; I would like to know what the modifier is for volatile and in which cases should I use it.…
-
13
votes2
answers668
viewsWhy is a Fibonacci faster in Java than in C?
Not exactly like this, but I noticed that when the function needs more time to compute Fibonacci, Java actually does better than C. Here are the implementations: C: #include<stdio.h> unsigned…
-
13
votes1
answer678
viewsCalling C functions from R
I need to optimize some functions that are in the C language, but using the packages of genetic algorithms in R. Is there any way to call C functions in R? In Matlab I know that there is this…
-
13
votes1
answer236
viewsIs it possible to interact a C# code with code external to . NET?
How to call code written in another language that is not part of . NET, for example the language C? How this interaction takes place? How to call native Windows functions?
-
13
votes4
answers4494
views -
13
votes1
answer816
viewsHow to make an excellent C++ program without C traces?
As a beginner in C++ I asked some questions here and was warned a few times by @Maniero that what I was doing was C and not C++. The problem is that C++ allows us to use many things similar to C. So…
-
12
votes4
answers8023
viewsWhen to use size_t?
Already research on the subject, but I always end up getting confused. I found a article in English that explains very well some reasons for the existence of the type and how to use it. According to…
-
12
votes2
answers1688
viewsDesign Patterns in C?
I’ve initiated the development of a system embedded in pure C. The project requires detailed documentation of software and hardware, as well as using the recommended design standards. It is known…
-
12
votes3
answers366
viewsVariable in main is global?
I read that global variables are those that we declare outside of all functions using #define and this way they could be used by all functions of a program. However, I was informed that the…
-
12
votes3
answers2963
viewsHow to measure the complexity of an algorithm?
I need to know if my algorithm meets the demand of the following statement: Implement an algorithm with O(n) complexity that performs the factorial of a number x such that x belongs to Naturals.…
casked 8 years, 9 months ago Murilo Formiga 163 -
12
votes3
answers13730
viewsWhat is the difference between simply-chained and double-chained list?
I’m having a hard time understanding the functioning and difference of a simply-chained list and a double-chained list, the two seem to have the same purpose and functioning. I know that both are…
-
12
votes2
answers1209
viewsHow to manipulate bit by bit an integer in c or ccs?
I want to change a bit an integer variable in C/CSS for pic. Ex: change some bit to turn another number. 15 = 0b00001111 -> 0b00001101 = 13.…
-
12
votes2
answers965
viewsIs there any way to run a java program (.jar) from a C or C++ program?
I wonder if there’s a way I can write a program .jar, and write a C/C++ program that called the JVM to run the file .jar. Is it possible? If so, can you give me an example of code or an instruction…
-
12
votes1
answer2664
viewsWhat are the characteristics of structured programming?
I would like to know what are the characteristics that define the paradigm of structured programming, and what is the difference of this paradigm with the paradigm of procedural programming? Both…
-
12
votes1
answer1550
viewsWhy can’t you declare a variable within a case?
Why don’t you compile? #include <stdio.h> int main(void) { int valor = 0; scanf("%d", &valor); switch (valor) { case 0: int variavel = 1; printf("%d", variavel); break; default: int…
-
12
votes1
answer9161
viewsWhat is Segmentation fault?
This error often occurs in code with problems. I don’t see it occurring in other languages. Why does it occur? What does it mean?
-
12
votes1
answer218
viewsHow does "free()" know how much memory it has to release?
When we use the malloc() we say how many bytes we need. But free() we do not say. How he knows how much he needs to be released?
-
12
votes1
answer1922
views -
12
votes2
answers1470
viewsWhat are the pointers?
I’ve come across this in several languages, mainly C and C++, but I’ve never understood what it is, how it’s used, and why it exists. I found out unintentionally that it also exists in C# and it’s a…
-
12
votes1
answer1392
viewsWhy, in C, does a function need to be declared before it is used?
This question was asked on Facebook. Lé is a problem because there is no room for a good answer, there is no way to classify the answers as to their quality properly, much appreciated by the…
-
11
votes3
answers31819
viewsRandom number range in C
In a certain program, I need to generate a random value greater than 1000 (with a limit set by me to up to 5000 (maybe it’s still too high)). This unique code refers to a type of registration to be…
-
11
votes2
answers1232
viewsUsing Java together with C
I am working on a micro controller project. My source is all in C however I would like to interact with this program using Java. Would that be possible? For example: The C program executes…
-
11
votes2
answers299
viewsC operator precedence table
In C why y = (y=2 , y+3) returns 5 if the + has priority over = and the ,?