{"id":39,"date":"2024-04-13T11:27:03","date_gmt":"2024-04-13T11:27:03","guid":{"rendered":"https:\/\/tuhintech.com\/tutorials\/?p=39"},"modified":"2024-04-13T11:27:07","modified_gmt":"2024-04-13T11:27:07","slug":"c-get-started","status":"publish","type":"post","link":"https:\/\/tuhintech.com\/tutorials\/c\/c-get-started\/","title":{"rendered":"C Get Started"},"content":{"rendered":"<section class=\"kc-elm kc-css-660146 kc_row\"><div class=\"kc-row-container  kc-container\"><div class=\"kc-wrap-columns\"><div class=\"kc-elm kc-css-265876 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-366459\"><nav class=\"menu-c-menu-container\" aria-label=\"Menu\"><ul id=\"menu-c-menu\" class=\"menu\"><li id=\"menu-item-25\" class=\"menu-item menu-item-type-post_type menu-item-object-post menu-item-25\"><a href=\"https:\/\/tuhintech.com\/tutorials\/c\/c-home\/\" class=\"menu-link\">C Home<\/a><\/li>\n<li id=\"menu-item-43\" class=\"menu-item menu-item-type-post_type menu-item-object-post menu-item-43\"><a href=\"https:\/\/tuhintech.com\/tutorials\/c\/c-home-2\/\" class=\"menu-link\">C Intro<\/a><\/li>\n<li id=\"menu-item-42\" class=\"menu-item menu-item-type-post_type menu-item-object-post menu-item-42\"><a href=\"https:\/\/tuhintech.com\/tutorials\/c\/c-get-started\/\" class=\"menu-link\">C Get Started<\/a><\/li>\n<\/ul><\/nav><\/div><\/div><\/div><div class=\"kc-elm kc-css-190415 kc_col-sm-9 kc_column kc_col-sm-9\"><div class=\"kc-col-container\"><div class=\"kc-elm kc-css-344306 kc_text_block\"><\/p>\n<h2>Get Started With C<\/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\u00a0<strong><em>IDE\u00a0<\/em><\/strong>(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 > New > Empty File<\/strong>.<\/p>\n<p>Write the following C code and save the file as\u00a0<code class=\"w3-codespan\">myfirstprogram.c<\/code>\u00a0(<strong>File > Save File as<\/strong>):<\/p>\n<div class=\"w3-example\">\n<h4>myfirstprogram.c<\/h4>\n<div class=\"w3-code notranslate javaHigh\">\n<p><span class=\"javacolor\">#include <stdio.<span class=\"javapropertycolor\">h<\/span>><\/p>\n<p><span class=\"javakeywordcolor\">int<\/span>\u00a0main() {<br \/>\u00a0 printf(<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<h2><img decoding=\"async\" class=\"w3-border\" src=\"https:\/\/www.w3schools.com\/c\/codeblocks2020.png\" \/><\/h2>\n<p>Then, go to\u00a0<strong>Build > 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.c<\/h3>\n<p>Code:<\/p>\n<div class=\"w3-code notranslate javaHigh\">\n<p><span class=\"javacolor\">#include <stdio.<span class=\"javapropertycolor\">h<\/span>><\/p>\n<p><span class=\"javakeywordcolor\">int<\/span>\u00a0main() {<br \/>\u00a0 printf(<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\/c\/tryc.php?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":[6],"tags":[],"class_list":["post-39","post","type-post","status-publish","format-standard","hentry","category-c"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/posts\/39"}],"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=39"}],"version-history":[{"count":2,"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"predecessor-version":[{"id":41,"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/posts\/39\/revisions\/41"}],"wp:attachment":[{"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tuhintech.com\/tutorials\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}