{"id":59,"date":"2024-04-13T12:36:54","date_gmt":"2024-04-13T12:36:54","guid":{"rendered":"https:\/\/tuhintech.com\/tutorials\/?p=59"},"modified":"2024-04-13T12:36:54","modified_gmt":"2024-04-13T12:36:54","slug":"c-get-started-2","status":"publish","type":"post","link":"https:\/\/tuhintech.com\/tutorials\/c-2\/c-get-started-2\/","title":{"rendered":"C++ Get Started"},"content":{"rendered":"<section class=\"kc-elm kc-css-215587 kc_row\"><div class=\"kc-row-container  kc-container\"><div class=\"kc-wrap-columns\"><div class=\"kc-elm kc-css-986807 kc_col-sm-3 kc_column kc_col-sm-3\"><div class=\"kc-col-container\"><div class=\"widget widget_nav_menu kc-elm kc-css-360410\"><h2 class=\"widgettitle\">C++ Tutorials<\/h2><nav class=\"menu-c-menu-3-container\" aria-label=\"C++ Tutorials\"><ul id=\"menu-c-menu-3\" class=\"menu\"><li id=\"menu-item-55\" class=\"menu-item menu-item-type-post_type menu-item-object-post menu-item-55\"><a href=\"https:\/\/tuhintech.com\/tutorials\/c-2\/c-home-3\/\" class=\"menu-link\">C++ Home<\/a><\/li>\n<li id=\"menu-item-69\" class=\"menu-item menu-item-type-post_type menu-item-object-post menu-item-69\"><a href=\"https:\/\/tuhintech.com\/tutorials\/c-2\/c-home-4\/\" class=\"menu-link\">C++ Introduction<\/a><\/li>\n<li id=\"menu-item-68\" class=\"menu-item menu-item-type-post_type menu-item-object-post menu-item-68\"><a href=\"https:\/\/tuhintech.com\/tutorials\/c-2\/c-get-started-2\/\" class=\"menu-link\">C++ Get Started<\/a><\/li>\n<\/ul><\/nav><\/div><\/div><\/div><div class=\"kc-elm kc-css-139058 kc_col-sm-9 kc_column kc_col-sm-9\"><div class=\"kc-col-container\"><div class=\"kc-elm kc-css-20067 kc_text_block\"><\/p>\n<h1>C++\u00a0<span class=\"color_h1\">Getting Started<\/span><\/h1>\n<div class=\"w3-clear nextprev\"><a class=\"w3-left w3-btn\" href=\"https:\/\/www.w3schools.com\/cpp\/cpp_intro.asp\">\u276e Previous<\/a><a class=\"w3-right w3-btn\" href=\"https:\/\/www.w3schools.com\/cpp\/cpp_syntax.asp\">Next \u276f<\/a><\/div>\n<hr \/>\n<h2>C++ Get Started<\/h2>\n<p>To start using C++, you need two things:<\/p>\n<ul>\n<li>A text editor, like Notepad, to write C++ code<\/li>\n<li>A compiler, like GCC, to translate the C++ code into a language that the computer will understand<\/li>\n<\/ul>\n<p>There are many text editors and compilers to choose from. In this tutorial, we will use an IDE (see below).<\/p>\n<hr \/>\n<h2>C++ Install IDE<\/h2>\n<p>An IDE (Integrated Development Environment) is used to edit AND compile the code.<\/p>\n<p>Popular IDE&#8217;s include Code::Blocks, Eclipse, and Visual Studio. These are all free, and they can be used to both edit and debug C++ code.<\/p>\n<p><strong>Note:<\/strong>\u00a0Web-based IDE&#8217;s can work as well, but functionality is limited.<\/p>\n<p>We will use\u00a0<strong>Code::Blocks<\/strong>\u00a0in our tutorial, which we believe is a good place to start.<\/p>\n<p>You can find the latest version of Codeblocks at\u00a0<a href=\"https:\/\/www.codeblocks.org\/downloads\/binaries\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.codeblocks.org\/<\/a>. Download the\u00a0<code class=\"w3-codespan\">mingw-setup.exe<\/code>\u00a0file, which will install the text editor with a compiler.<\/p>\n<hr \/>\n<h2>C++ Quickstart<\/h2>\n<p>Let&#8217;s create our first C++ file.<\/p>\n<p>Open Codeblocks and go to\u00a0<strong>File &gt; New &gt; Empty File<\/strong>.<\/p>\n<p>Write the following C++ code and save the file as\u00a0<code class=\"w3-codespan\">myfirstprogram.cpp<\/code>\u00a0(<strong>File &gt; Save File as<\/strong>):<\/p>\n<div class=\"w3-example\">\n<h4>myfirstprogram.cpp<\/h4>\n<div class=\"w3-code notranslate javaHigh\">\n<p><span class=\"javacolor\">#include &lt;iostream&gt;<br \/>using namespace std;<\/p>\n<p><span class=\"javakeywordcolor\">int<\/span>\u00a0main() {<br \/>\u00a0\u00a0cout &lt;&lt;\u00a0<span class=\"javastringcolor\">&#8220;Hello World!\"<\/span>;<br \/>\u00a0\u00a0<span class=\"javakeywordcolor\">return<\/span>\u00a0<span class=\"javanumbercolor\">0<\/span>;<br \/>}<\/span><\/div>\n<\/div>\n<p>Don&#8217;t worry if you don&#8217;t understand the code above &#8211; we will discuss it in detail in later chapters. For now, focus on how to run the code.<\/p>\n<p>In Codeblocks, it should look like this:<\/p>\n<h1><img decoding=\"async\" class=\"w3-border\" src=\"https:\/\/www.w3schools.com\/cpp\/codeblocks2020.png\" \/><\/h1>\n<p>Then, go to\u00a0<strong>Build &gt; Build and Run<\/strong>\u00a0to run (execute) the program. The result will look something to this:<\/p>\n<div class=\"w3-example w3-padding-16\">\n<div class=\"notranslate w3-black w3-padding\"><code>Hello World!<br \/>Process returned 0 (0x0) execution time : 0.011 s<br \/>Press any key to continue.<\/code><\/div>\n<\/div>\n<p><strong>Congratulations<\/strong>! You have now written and executed your first C++ program.<\/p>\n<hr \/>\n<h2>Learning C++ At W3Schools<\/h2>\n<p>When learning C++ at W3Schools.com, you can use our &#8220;Try it Yourself\" tool, which shows both the code and the result. This will make it easier for you to understand every part as we move forward:<\/p>\n<div class=\"w3-example\">\n<h3>myfirstprogram.cpp<\/h3>\n<p>Code:<\/p>\n<div class=\"w3-code notranslate javaHigh\">\n<p><span class=\"javacolor\">#include &lt;iostream&gt;<br \/>using namespace std;<\/p>\n<p><span class=\"javakeywordcolor\">int<\/span>\u00a0main() {<br \/>\u00a0\u00a0cout &lt;&lt;\u00a0<span class=\"javastringcolor\">&#8220;Hello World!\"<\/span>;<br \/>\u00a0\u00a0<span class=\"javakeywordcolor\">return<\/span>\u00a0<span class=\"javanumbercolor\">0<\/span>;<br \/>}<\/span><\/div>\n<p>Result:<\/p>\n<div class=\"notranslate w3-black w3-padding\"><code>Hello World!<\/code><\/div>\n<p><a class=\"w3-btn w3-margin-bottom w3-margin-top\" href=\"https:\/\/www.w3schools.com\/cpp\/trycpp.asp?filename=demo_helloworld\" target=\"_blank\" rel=\"noopener\">Try it Yourself \u00bb<\/a><\/div>\n<p>\n<\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"site-sidebar-layout":"no-sidebar","site-content-layout":"","ast-site-content-layout":"full-width-container","site-content-style":"boxed","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[8],"tags":[],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-c-2"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/posts\/59"}],"collection":[{"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":1,"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":60,"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/posts\/59\/revisions\/60"}],"wp:attachment":[{"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/media?parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/categories?post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/tags?post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}