Questions tagged [c]

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

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

It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.

Reading list:

1301 questions
282
votes
7 answers

How to write a very basic compiler

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 according to library and functions of the…
Googlebot
  • 3,173
  • 5
  • 19
  • 14
228
votes
8 answers

When do you use float and when do you use double

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 more subjective. If I would be confronted to…
Jakub Zaverka
  • 2,429
  • 2
  • 14
  • 8
199
votes
10 answers

Is every language written in C?

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 all languages? Is each concept (OOP, etc.) all…
FaizanHussainRabbani
  • 2,255
  • 2
  • 15
  • 22
169
votes
18 answers

Is there any reason to use C++ instead of C, Perl, Python, etc.?

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 languages like Perl and Python would be good…
Ehsan
  • 853
  • 3
  • 8
  • 9
163
votes
12 answers

When to use C over C++, and C++ over C?

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 such scripting languages are usually deemed…
Dark Templar
  • 6,223
  • 16
  • 46
  • 46
153
votes
7 answers

Was the C programming language considered a low level language when it came out?

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 and beyond so I'm curious if and how the nature of…
joeyfb
  • 1,229
  • 2
  • 9
  • 9
152
votes
6 answers

Why hasn't a faster, "better" language than C come out?

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 things, and C has been around for a really long time…
Jason
  • 2,037
  • 2
  • 17
  • 16
144
votes
11 answers

Should I stop using the term C/C++?

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, C++11 (or the modern C++ 11/14/17 in general). In…
rkachach
  • 1,219
  • 2
  • 9
  • 9
136
votes
16 answers

Why do people use C if it is so dangerous?

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 the gets function so dangerous that it should not be…
Tristan
  • 1,295
  • 2
  • 9
  • 11
129
votes
8 answers

Is it better to document functions in the header file or the source file?

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 current time * * Example: * printf("Now is %lu…
Joey Adams
  • 5,535
  • 3
  • 30
  • 34
112
votes
7 answers

Why declare a variable in one line, and assign to it in the next?

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 = &something_else; I initially assumed that this was a…
Jonathan Sterling
  • 1,606
  • 2
  • 12
  • 14
109
votes
12 answers

Is the C programming language still used?

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 surprise when one of my friends said that she…
Pankaj Upadhyay
  • 5,060
  • 11
  • 44
  • 60
104
votes
3 answers

When and for what purposes should the const keyword be used in C for variables?

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 various situations when it can be useful. Should it…
Aseem Bansal
  • 2,954
  • 6
  • 20
  • 33
104
votes
4 answers

How is a Java reference different from a C pointer?

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 reference also store the address? How they are…
Gnijuohz
  • 2,035
  • 4
  • 20
  • 18
100
votes
3 answers

Why do programming languages, especially C, use curly braces and not square ones?

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 doesn't require the shift key at least on US…
SomeKittens
  • 4,220
  • 6
  • 31
  • 38
1
2 3
86 87