C programming
An open textbook from Wikibooks, a chapter a page, in reading order.
18 sidorUppdaterad
Version: 1CC BY-SA 4.0
[C]( is the most commonly used programming language for writing [operating systems]( The first operating system written in C was [Unix]( Later operating systems like [GNU/Linux]( were all written in C. Not only is C the language of operating systems, but it is also the precursor and inspiration for
Version: 1CC BY-SA 4.0
The Algorithmic Language ([Algol 58]( was derived from Fortran in 1958 and evolved into [Algol 60]( in 1960. The [Combined Programming Language (CPL)]( was then created out of Algol 60 in 1963. In 1967, it evolved into [Basic CPL]( (BCPL), which was the basis for [B]( which was created in 1971, and
Version: 1CC BY-SA 4.0
It's also assumed you have some experience interacting with your operating system through a terminal window using its **command line interface.** If you aren't sure what this means, consider seeking out a tutorial for your chosen platform that can get you comfortable with getting around your compute
Version: 1CC BY-SA 4.0
Therefore, you can use Dev C++ for C development. However, Dev C++ is not the compiler. It is designed to use the [MinGW]( or [Cygwin]( versions of [GCC]( - both of which can be obtained as part of the Dev C++ package, although they are completely different projects. Dev C++ simply provides an edito
Version: 1CC BY-SA 4.0
Though your compiler understands it, you can only guess at what the code, sprinkled with some familiar English words, might do. One of your first jobs as a new programmer will be to learn the many "words" and symbols of the C programming language, the language your compiler understands. Once you lea
Version: 1CC BY-SA 4.0
Before learning C syntax and programming constructs, it is important to learn the meaning of a few key terms that are central in understanding C, as well as the basic structure of a C program. So what is in a block? Generally, a block consists of executable statements. ## Statements A statement can
Version: 1CC BY-SA 4.0
Having covered the basic concepts of C programming, we can now briefly discuss the process of compilation. Like any programming language, C by itself is completely incomprehensible to a [microprocessor]( Its purpose is to provide an intuitive way for humans to provide instructions that can be easily
Version: 1CC BY-SA 4.0
Machines process things. We feed stuff into a machine and get different stuff out. A saw turns trees into planks. An internal combustion engine turns gasoline into rotational energy.
Version: 1CC BY-SA 4.0
Now that we can create variables, let's learn how to fill those variables with input from the user. Like the output functions from [Simple output]( these input functions are declared in stdio.h, part of the C standard library. ## Input using scanf() The scanf() function is the input method equivalen
Version: 1CC BY-SA 4.0
Its type depends on its form and value. The types of constants are character constants (e.g. ' ' is a space), integer constants (e.g. 2), floating-point constants (e.g.
Version: 1CC BY-SA 4.0
In C programming, all executable code resides within a **function**. Note that other programming languages may distinguish between a "function", "subroutine", "subprogram", "procedure", or "method" -- in C, these are all functions. Functions are a fundamental feature of any high level programming la
Version: 1CC BY-SA 4.0
A library in C is a collection of header files, exposed for use by other programs. The library therefore consists of an interface expressed in a .h file (named the "header") and an implementation expressed in a .c file. This .c file might be precompiled or otherwise inaccessible, or it might be avai
Version: 1CC BY-SA 4.0
Why doesn't it work? ### Data types - List at least three data types in C
On your computer, how much memory does each require? - Which ones can be used in place of another? Why?
Version: 1CC BY-SA 4.0
In the chapter [Variables]( we looked at the primitive data types. However, more advanced data types allow us greater flexibility in managing data in our program. ## Structs Structs are data types made of variables of other data types (possibly including other structs). They are used to group pieces
Stöd den här publikationen
Varje månad, via Stripe. Efter Stripes avgift och Hub Nexus 14 % går hälften av varje betalning till kuratorerna och hälften till författarna av sidorna i den, efter hur många sidor var och en skrivit.



