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
-
88
votes3
answers6231
viewsWhat does "??!?!" mean in C language?
Once I saw a code in C with the following line: ... if (condicao1 ??!??! condicao2){ /* faca algo */ } ... What does "??!?!" mean in C language?
-
82
votes5
answers17889
viewsWhy choose C instead of C++ or C++ instead of C?
I think everyone with the least amount of knowledge knows when to choose C or C++ over other languages. There are clear cases where these languages are more suitable and others that do not make so…
-
59
votes3
answers6039
viewsWhat’s the difference between DLL and lib?
I know that .dll and .lib are libraries, the first is dynamic and the second is static. But what does it really mean? How does each one work? If I have to generate a library from a code, what I…
-
56
votes4
answers3125
viewsPrecise math division
In Windows calculator: 9/3,0001 = 2,999... In my program: 9/3,0001 = 3; I would like to get that level of accuracy using C. Watch excerpts from my program: double op(double num1, double num2, char…
-
49
votes2
answers1582
viewsHow can -1 be greater than 4?
How this code can execute in this way? #include <stdio.h> int main(void) { printf("tamanho de um inteiro: %d\n", sizeof(int)); if(sizeof(int) > -1) { printf("4 é maior que -1"); } else {…
-
46
votes5
answers9524
viewsReceive an expression and calculate in C
I am developing this program that should receive an expression from the user and do the calculation. Ex: Insert an expression 3*5-1 14 My problem is how to handle the user-sent expression. I was…
-
45
votes6
answers2425
viewsArrays are pointers, right?
After all, in C, an array a[] becomes a pointer *a? If not, what are arrays? What are the differences between them? How arrays work internally?
-
39
votes3
answers23304
viewsWhat is the difference between "passing by value" and "passing by reference"?
I know that in the first the object passed as an argument to a function is copied, and in the second not. I also know that it is extremely unusual in modern languages to pass complex objects by…
-
38
votes3
answers2673
viewsHow to make "case-insensitive" comparisons in Sqlite?
Since there’s an obsession with accent questions, here goes mine :) Sqlite allows direct comparisons or through like with any encoding/charset as long as it’s done byte to byte. It only allows…
-
38
votes2
answers1031
viewsWhy use "while(0)"?
In Linux code I saw some macros with: do { }while(0) Is there a reason? Because there seems to be no logic in a repeat loop where the code repeats only once.
-
35
votes2
answers998
viewsA C compiler can generate a 64-bit executable where pointers are 32-bit?
Most programs fit well into address space of less than 4GB, but in some cases the program may need to use new processor features/instructions that are only available on x64 architecture.…
-
33
votes4
answers41801
views -
32
votes1
answer512
viewsArduino I2C sends unexpected NACK
I’m wearing a Development board of microchip (explorer 16) with the pic24f128ga010 as Master and the Arduino as Slave. The PIC is sending everything right, but for some reason NACK for all the date,…
-
31
votes3
answers13759
viewsDifference between %i and %d
Is there any difference between printf("%d", x); and printf("%i", x);? I know the two return the same result, have some kind of convention adopted to always use the %d?…
-
30
votes1
answer1075
viewsPolymorphism in procedural language
One of the characteristics of object orientation is polymorphism, the ability of a method to perform different behaviors according to the context that can be defined by a hierarchy…
-
30
votes1
answer1625
viewsWhen does Stack Overflow occur?
A question that has everything to do with the name of this site. We know that one of the most commonly used examples to demonstrate the execution stack of a program is recursion. A recursive…
-
29
votes1
answer12710
viewsHow to read from stdin in C?
How should I read characters, digits and strings stdin? getchar; fgetc; fgets; getc; scanf; I’m here trying to read from the console and there’s always something wrong with reading it. I have tried…
-
29
votes2
answers1063
viewsChallenge of the Ant Colony
I have a programming marathon problem and I want to know if my solution is right, as well as improvement suggestions. Problem A group of ants are really proud because they have built a magnificent…
-
28
votes6
answers1852
viewsC programming for ARM
I’ll start a project in C that will have as target a plaque Colibri T20, processor-equipped NVIDIA Tegra 2 ARM, running a light version of Linux. I wonder if, in addition to having to use a cross…
-
25
votes3
answers2778
viewsWhat is the purpose of "continue" in C?
int main () { /* local variable definition */ int a = 10; /* do loop execution */ do { if( a == 15) { /* skip the iteration */ a = a + 1; continue; } printf("value of a: %d\n", a); a++; }while( a…
-
24
votes3
answers739
viewsWhat does ":-!!" mean in C language?
In a Linux kernel library, specifically this: /usr/include/linux/kernel. h, there’s a macro with a code strange to me: /* Force a compilation error if condition is true, but also produce a result…
-
24
votes3
answers1024
viewsShould I free up all the allocated memory when finishing a program?
It is commonly accepted that when I allocate a block of memory I am responsible for releasing it. This is particularly true when programming based on RAII. However the following program works…
-
23
votes2
answers1963
viewsWhat is the purpose of the free() function?
In which cases should it be used? There is an alternative? It is recommended to use?
-
23
votes1
answer9539
viewsWhat is the difference between "calloc()" and "malloc()"?
What the function calloc() makes the malloc() Doesn’t it? Why is it hardly used?
-
23
votes2
answers1397
viewsHow to calculate the value of a polynomial function at an arbitrary point?
I need to calculate the value of a polynomial function of arbitrary grade in arbitrary values of the realm. I would like to know how to do it in a way that is not naive when doing the floating point…
-
22
votes3
answers1767
viewsWhat prevents an array from being initialized with a variable size in C?
Why does an array need to have a constant size? What prevents it from having a variable size?
-
21
votes3
answers4426
viewsIn practice, what is the use of C-pointers?
Recently I have been studying the language and so far I have not identified practical utility for the use of pointers. I understand how it works very well, but nothing more.
-
20
votes3
answers523
viewsWhy does C array[6] equal 6[array]?
Note: Question I saw in ONLY in English, but I found it interesting to put here (because we still don’t have many questions of C): Because in the C language, this code prints "true"? #include…
-
20
votes4
answers6387
views -
20
votes4
answers2408
viewsWhat is buffer overflow?
Whenever I use the function gets() the compiler returns me the following warning: Function is Dangerous and should not be used Translation: this function is dangerous and should not be used I hear a…
-
20
votes2
answers13387
viewsWhat is the difference between "NULL", "0" and 0?
Both are worth zero. I can use the 3 interchangeably always?
-
19
votes1
answer941
viewsHow does C/C++ "padding work?
In several responses here at Stackoverflow I have noticed users commenting on padding in data structures. struct { int a; char b; float d; } What is this one padding (filling) that exists between…
-
19
votes2
answers9703
viewsIs it possible to program object oriented in C?
There is the possibility to build a C program using POO? I have looked on several websites for examples of this, but I have found nothing concrete, which tells me whether or not it really gives. If…
-
19
votes2
answers468
viewsMeaning of "__"
In the implementation of the Linux kernel, I came across this statement on line 89: #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) I know that in C, symbols…
-
19
votes1
answer639
viewsWhat happens when we call a function?
At the machine instruction level, what will happen on the call?
-
19
votes5
answers5742
viewsIs it possible to develop websites with C/C++?
I know a little bit of PHP, but I see that on content sites, sometimes it gives a crashes and etc. Researching, I saw reports (very superficial) that it is possible to develop web applications with…
-
18
votes3
answers10342
viewsWhat are Unions? Why use them within structs?
I’d like to understand the differences between union and struct. I realized that both can be accessed in the same way: u.membro uPrt->membro s.membro sPrt->membro In practice I have seen…
-
18
votes3
answers18194
viewsWhat purpose of unsigned in C++
What is the purpose of unsigned in the C++? Example: unsigned char ch2;
-
18
votes2
answers22927
viewsWhat is the meaning of the "&" (commercial) operator in the C language?
I am putting together a workbook in C and I am looking for a clear way to explain this operator to the reader, and I believe that this question will help the people who are starting. Take an…
-
17
votes1
answer23130
viewsHow to pass a function as parameter in C?
I wanted to know how the function passed by parameter as it happens in pthread_create (thread,atributo,rotina,argumento);. On the field rotina a function is placed in void*.…
-
17
votes1
answer410
viewsDiscrepant running times in parallel programming
I made a parallel code in C in order to verify its execution time. Was treated: Threads; Mutex; False Sharing; Synchronization. When executing the time of Linux with the execution of the code, in…
-
17
votes4
answers793
viewsSimple Teaching of Pointers
I’m a sporadic programmer, and whenever I need to use pointers, I realize I’ve forgotten how to use it, and I have to work hard to learn everything again. Does anyone have any simple didactics to…
-
17
votes2
answers40473
viewsHow to create a vector of variable size?
In C language, it is possible to create a vector of any type so that its size is variable? If possible, how to do?
-
17
votes1
answer484
viewsData access performance in heap and stack and object allocation
Data access in the stack is faster than in heap? And why allocate an object to heap?
-
17
votes1
answer1949
viewsWhenever I am going to scan a string in C I must use "strlen()", right?
It is common to see in C execs that people need to analyze and/or manipulate the content of a string, then we need to make sure that it will not exceed its limit. It is very common to make a for…
-
17
votes4
answers359
viewsOutput a C code with pointers
I need to understand what each of the values printed on the screen means by the following code: #include<stdio.h> int main() { int i=5; int *p; p = &i; printf("%u %d %d %d %d \n", p,…
-
16
votes1
answer673
viewsDoes compiling on your computer really improve performance?
Any programmer knows that when building a C/C++, the compiler can optimize the code to generate faster executables. But, it is also said that there is the compiler optimization for your processor.…
-
16
votes2
answers17517
viewsReal difference between point operator (.) and arrow operator (->) in C?
What is the real difference between the two operators. I know the operator (->) is used when the variable is a pointer, and that it is equivalent to (*ptr).membro. Well, if I declare a pointer of…
-
16
votes5
answers2736
viewsTest whether all characters of the first string also appear in the second
I’m trying to do that function with the help of the functions strcmp() and strncmp() and I’m not having much success. Let’s say I have the string char s[] = "abc" and another string char v[] =…
-
16
votes1
answer462
viewsSecurity - Syscall inside shellcode does not run
I’m studying information security and doing experiments trying to exploit a classic case of buffer overflow. I succeeded in creating the shellcode, in its injection into the code and its execution,…