Skip to main content

Questions tagged [c]

C is a general-purpose computer programming language used for operating systems, games and other high performance work.

Filter by
Sorted by
Tagged with
290 votes
7 answers
453k views

Advanced compilers like gcc compile code into machine readable files according to the language in which the code has been written (e.g. C, C++, etc). In fact, they interpret the meaning of the code ...
Googlebot's user avatar
  • 3,253
229 votes
8 answers
302k views

Frequently, in my programming experience, I need to make a decision whether I should use float or double for my real numbers. Sometimes I go for float, sometimes I go for double, but really this feels ...
Jakub Zaverka's user avatar
201 votes
10 answers
84k views

Sometimes while programming in different languages (C/C++, C#), this thought comes to my mind: Is each and every language written in the C programming language? Is the C language the mother/father of ...
FaizanHussainRabbani's user avatar
170 votes
18 answers
202k views

As a Linux (server side) developer, I don't know where and why should I use C++. When I'm going for performance, the first and last choice is C. When "performance" isn't the main issue, programming ...
163 votes
12 answers
527k views

I've been introduced to Computer Science for a little over a year now, and from my experience it seems that C and C++ are both considered to be "ultrafast" languages, whereas others such as Python and ...
156 votes
7 answers
29k views

Currently C is considered a low level language, but back in the 70's was it considered low level? Was the term even in use then? Many popular higher level languages didn't exist until the mid 80's ...
joeyfb's user avatar
  • 1,259
152 votes
6 answers
44k views

With all the new "modern" languages out today, how is it that C is still heralded as the fastest and "closest to the machine"? I don't really believe in there ever being only one correct way to do ...
145 votes
11 answers
25k views

I understand C and C++ are different languages but when I was learning C++ I was always told that C is a subset of C++ or C++ is C with classes. And that was quite true until the appearance of C++x0, ...
rkachach's user avatar
  • 1,229
137 votes
8 answers
110k views

In languages that distinguish between a "source" and "header" file (mainly C and C++), is it better to document functions in the header file: (pilfered from CCAN) /** * time_now - return the ...
Joey Adams's user avatar
  • 5,645
135 votes
16 answers
52k views

I am considering learning C. But why do people use C (or C++) if it can be used 'dangerously'? By dangerous, I mean with pointers and other similar stuff. Like the Stack Overflow question Why is ...
Tristan's user avatar
  • 1,285
114 votes
7 answers
65k views

I often see in C and C++ code the following convention: some_type val; val = something; some_type *ptr = NULL; ptr = &something_else; instead of some_type val = something; some_type *ptr = &...
Jonathan Sterling's user avatar
109 votes
12 answers
223k views

I am a C# programmer, and most of my development is for websites along with a few Windows applications. As far as C goes, I haven't used it in a long time, as there was no need to. It came to me as a ...
108 votes
3 answers
97k views

While getting my code reviewed here the issue of using the const keyword came up. I understand that it is used for implementing read-only behaviour on variables. I am confused about what are the ...
Aseem Bansal's user avatar
  • 3,044
107 votes
4 answers
73k views

C has pointers and Java has what is called references. They have some things in common in the sense that they all point to something. I know that pointers in C store the addresses they point to. Do ...
Gnijuohz's user avatar
  • 2,075
98 votes
6 answers
29k views

For example, the SysInternals tool "FileMon" from the past has a kernel-mode driver whose source code is entirely in one 4,000-line file. The same for the first ever ping program ever written (~2,000 ...
Bran's user avatar
  • 863
98 votes
3 answers
51k views

The definition of "C-Style language" can practically be simplified down to "uses curly braces ({})." Why do we use that particular character (and why not something more reasonable, like [], which ...
SomeKittens's user avatar
  • 4,238
96 votes
15 answers
54k views

I code a lot in both C and C++, but did not expect C to be the second most popular language, slightly behind Java. TIOBE Programming Community Index I'm curious as to why, in this age of OOP, C is ...
96 votes
5 answers
34k views

There are some programming languages for which exist a package management system: CTAN for TeX CPAN for Perl Pip & Eggs for Python Maven for Java cabal for Haskell Gems for Ruby npm for NodeJS ...
m0nhawk's user avatar
  • 1,488
92 votes
16 answers
21k views

Why did the C master Dennis Ritchie introduce pointers in C? And why did the other programming languages like VB.NET or Java or C# eliminate them? I have found some points in Google, and I want to ...
92 votes
5 answers
189k views

What things should absolutely always/never be included in a header file? Functions: what must go in the header file and what mustn't Constants: Is it good practice to define lot of constants in a ...
Moshe Magnes's user avatar
  • 1,071
86 votes
19 answers
74k views

I've always heard that C is the language of choice to use for embedded systems, or anything that needs to run at maximum speed. I never developed a fondness for C, mostly because I don't like pointer ...
Juliet's user avatar
  • 2,787
83 votes
8 answers
18k views

I heard that you should avoid leading newlines when using printf. So that instead of printf("\nHello World!") you should use printf("Hello World!\n") In this particular example ...
klutt's user avatar
  • 1,448
82 votes
12 answers
53k views

I'm trying to understand the difference between procedural languages like C and object-oriented languages like C++. I've never used C++, but I've been discussing with my friends on how to ...
niko's user avatar
  • 2,119
81 votes
10 answers
25k views

What was the reasoning behind not explicitly storing an array's length with an array in C? The way I see it, there are overwhelming reasons to do so but not very many in support of the standard (C89)....
VF1's user avatar
  • 1,891
80 votes
20 answers
8k views

Sometimes you run into a situation where you have to extend/improve some existing code. You see that the old code is very lean, but it's also difficult to extend, and takes time to read. Is it a good ...
80 votes
14 answers
32k views

When a C program is running, the data is stored on the heap or the stack. The values are stored in RAM addresses. But what about the type indicators (e.g., int or char)? Are they also stored? ...
user16307's user avatar
  • 907
78 votes
10 answers
50k views

My understanding is that in the 1980s, and perhaps in the 1990s too, Pascal and C were pretty much head-to-head as production languages. Is the ultimate demise of Pascal only due to Borland's neglect ...
Konrad Morawski's user avatar
73 votes
5 answers
31k views

C is one of the most widely-used languages in the world. It accounts for a huge proportion of existing code and continues to be used for a vast amount of new code. It's beloved by its users, it's so ...
user avatar
70 votes
12 answers
36k views

I really hesitate to ask this, because I don't want to "solicit debate, arguments, polling, or extended discussion" but I'm new to C and want to gain more insight into common patterns used in the ...
Robz's user avatar
  • 1,653
70 votes
19 answers
5k views

Many questions and answers on the C/C++ pages, specifically or indirectly discuss micro performance issues (such is the overhead of an indirect vs direct vs inline function), or using an O(N2) vs O(...
68 votes
10 answers
21k views

Languages like C, Java, and C++ all require parenthesis around an entire expression when used in an if, while, or switch. if (true) { // Do something } as opposed to if true { // Do ...
Velovix's user avatar
  • 773
65 votes
9 answers
31k views

I'm cleaning up the includes in a C++ project I'm working on, and I keep wondering whether or not I should explicitly include all headers used directly in a particular file, or whether I should only ...
futlib's user avatar
  • 2,205
64 votes
11 answers
20k views

A few months ago, we started developing an app to control an in-house developed test equipment and record a set of measurements. It should have a simple UI, and would likely require threads due to the ...
rick's user avatar
  • 2,005
64 votes
3 answers
50k views

Assumptions One of the advantages of header-only libraries for C++ is that they do not need to be compiled separately. In C and C++ inline makes sense only if the function is defined in a header file*...
Vorac's user avatar
  • 7,189
63 votes
10 answers
12k views

So I am working on a software design using C for a certain processor. The tool-kit includes the ability to compile C as well as C++. For what I am doing, there is no dynamic memory allocation ...
Snoop's user avatar
  • 2,758
63 votes
8 answers
16k views

I recently was wondering when to use C over C++, and vice versa? Fortunately someone already beat me to it and although it took a while, I was able to digest all the answers and comments to that ...
smeeb's user avatar
  • 4,970
63 votes
11 answers
2k views

I am very eager to study best practices when it comes to space hardening. For instance, I've read (though I can't find the article any longer) that some core parts of the Mars rovers did not use ...
user avatar
63 votes
13 answers
10k views

C\C++ specifications leave out a large number of behaviors open for compilers to implement in their own way. There are a number of questions that always keep getting asked here about the same and we ...
Alok Save's user avatar
  • 1,138
63 votes
9 answers
17k views

As a good programmer one should write robust codes that will handle every single outcome of his program. However, almost all functions from the C library will return 0 or -1 or NULL when there's an ...
Derek 朕會功夫's user avatar
60 votes
6 answers
41k views

What is the advantage of returning a pointer to a structure as opposed to returning the whole structure in the return statement of the function? I am talking about functions like fopen and other low ...
yoyo_fun's user avatar
  • 2,297
60 votes
2 answers
94k views

I have heard that it is a good practice to write functions that do not receive anything as a parameter like this: int func(void); But I hear that the right way to express that is like this: int func(...
Grizzly's user avatar
  • 629
59 votes
2 answers
21k views

Reading 21st Century C I arrived at chapter 6 at the section "Marking Exceptional Numeric Values with NaNs", where it explains the use of the bits in the mantissa to store some arbitrary bit ...
andijcr's user avatar
  • 701
58 votes
15 answers
95k views

My first programming language was PHP (gasp). After that I started working with JavaScript. I've recently done work in C#. I've never once looked at low or mid level languages like C. The general ...
57 votes
15 answers
7k views

Disclaimer: I know perfectly well the semantics of prefix and postfix increment. So please don't explain to me how they work. Reading questions on stack overflow, I cannot help but notice that ...
fredoverflow's user avatar
  • 6,954
56 votes
11 answers
24k views

I use unsigned ints everywhere, and I'm not sure if I should. This can be from database primary key id columns to counters, etc. If a number should never be negative, then I will always used an ...
wting's user avatar
  • 1,044
56 votes
6 answers
288k views

I was reading a thread titled "strlen vs sizeof" on CodeGuru, and one of the replies states that "it's anyways [sic] bad practice to initialie [sic] a char array with a string literal." Is this true,...
Cole Tobin's user avatar
  • 1,533
55 votes
5 answers
41k views

Stroustrup claims that Cfront, the first C++ compiler, was written in C++ (Stroustrup FAQ). However, how is it even possible that the first C++ compiler be written in C++? The code that makes up the ...
Pacerier's user avatar
  • 5,063
53 votes
9 answers
53k views

I read from somewhere that when using C++ it is recommended not to use pointers. Why is pointers such a bad idea when you are using C++. For C programmers that are used to using pointers, what is the ...
Joshua Partogi's user avatar
52 votes
4 answers
17k views

When compiling C code and looking at assembly, it all has the stack grow backwards like this: _main: pushq %rbp movl $5, -4(%rbp) popq %rbp ret -4(%rbp) - does this mean the ...
alex's user avatar
  • 519
51 votes
8 answers
26k views

Java has an automatic GC that once in a while Stops The World, but takes care of garbage on a heap. Now C/C++ applications don't have these STW freezes, their memory usage doesn't grow infinitely ...
Ju Shua's user avatar
  • 703

1
2 3 4 5
27