by admin
Your First C++ Dev-c++
- My first IDE. If you want to learn the basics I would say Dev-C should still be your first choice, people still use CVS and they kept everything simple. Less IDE overhead means less confusion and more focus on the core of the language. (I hope they weren't secretly bought out by some large corporation, but I guess that could be a good thing.).
- Aug 11, 2016 This video will show you how to compile and run your first C program using the IDE (Integrated Development Environment) Dev-C.Install DeV C-First C Project (Hello World).
About C Programming. Multi-paradigm Language - C supports at least seven different styles of programming. Developers can choose any of the styles. General Purpose Language - You can use C to develop games, desktop apps, operating systems, and so on. Speed - Like C programming, the preformance of optimized C code is exceptional.
Originally released by Bloodshed Software, but abandoned in 2006, it has recently been forked by Orwell, including a choice of more recent compilers. It can be downloaded from:
http://orwelldevcpp.blogspot.com
Installation
Run the downloaded executable file, and follow its instructions. The default options are fine.Support for C++11
By default, support for the most recent version of C++ is not enabled. It shall be explicitly enabled by going to:Tools -> Compiler Options
Here, select the 'Settings' tab, and within it, the 'Code Generation' tab. There, in 'Language standard (-std)' select 'ISO C++ 11':
Ok that. You are now ready to compile C++11!
Compiling console applications
To compile and run simple console applications such as those used as examples in these tutorials it is enough with opening the file with Dev-C++ and hitF11
.As an example, try:
File -> New -> Source File
(or Ctrl+N
)There, write the following:
Then:
File -> Save As..
(or Ctrl+Alt+S
)And save it with some file name with a
.cpp
extension, such as example.cpp
.Now, hitting
F11
should compile and run the program.If you get an error on the type of
x
, the compiler does not understand the new meaning given to auto
since C++11. Please, make sure you downloaded the latest version as linked above, and that you enabled the compiler options to compile C++11 as described above.Tutorial
You are now ready to begin the language tutorial: click here!.
The following is one of the most basic programs that is possible to write in C++. This should give you a first feel of how you can get a computer to do things for you. Be sure to click the Run this code button which will compile and run the code on the server.
Dev C++ Program Download
Output:
Poner color al fondo en programa en dev c. Let's analyze the code line by line.
#include <iostream>
- #include is a preprocessor directive that allows code to include functionality from somewhere else. In this case, the standard
iostream
library is included. It contains the declaration ofstd::cout
, which we use later; without this line, the compiler would not recognizestd::cout
that appears later, and we would get an error.
int main()
- This is the main function. The main function is a function that defines the user code which is run when the program is launched. Every program must have a function called main, otherwise the computer would not know where to start the program.
- All function definitions have four parts:
- A return type (in this case
int
), which specifies what value is returned to the code that calls the function.
- A name (in this case
main
), which identifies the function.
- A parameter list (in this case empty), which specifies what data can be passed to the function by the code that calls the function. In this case the parameter list is empty. The parameter list is always enclosed in parentheses.
- A function body (in this case std::cout<<'Hello world!n';return0;) - a sequence of statements that identify the actions that the function will perform. The function body is always enclosed within curly braces (
{
and}
).
std::cout << 'Hello World!n';
- This is the line where all the action of printing
Hello World!
to the screen is described. The line contains a single statement, which ends at;
. Let's examine what the statement does.std::cout
is the name of special object that represents console output.<<
is an operator (like a+
or/
operators), which instructs the compiler to generate code to print tostd::cout
(console) whatever comes after the<<
operator. In this case this is the text 'Hello worldn'. Then
part is a special character that identifies a newline. Such characters are called escape sequences.
- The
std::
prefix ofstd::cout
indicates that the object comes from the standard library. It is possible to save some typing and usestd::cout
withoutstd::
, ascout
, but only ifusing namespace std;
is present somewhere above. We advise against this practice, because the standard library contains many simple names, such asstd::count
,std::list
, etc. In more complex programs, some of your own variables might be named ascount
orlist
, which will lead to ambiguities and hard to debug bugs in your program. It's better to always usestd::
. Omitting it doesn't save a lot of time, since as the time goes, you'll learn to typestd::
very fast :)
How To Run C++ Program In Dev C++
return 0;
- This is the return statement. At this point, the
main
function is terminated.0
is the return value. In the case ofmain
, the return value indicates to the operating system, whether the program has finished successfully or not. Here we return0
, which indicates successful execution.
Dev C++ Download For Laptop
Retrieved from 'https://en.cppreference.com/bookwiki/index.php?title=intro/hello_world&oldid=920'