Thread: Creating My First Project with Code::Blocks

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    113

    Creating My First Project with Code::Blocks

    Hello everyone,

    I have learnt a bit C programming but used the language for the case specific small tasks and always implemented all the functions I needed to one file. This time I have decided to create my first generalised application but I have got some problems.

    I am trying to write a heat transfer solver. I will start with a simple 1D, steady state solver. I created files for different things. For example I created a file called Initializer.c including the init function which initialises the arrays in the application.

    I created a project and add this file to my project. In main.c file I wrote #include <Initializer.c>. However, when building the project it says "No such file or directory". Can someone help me how I can use the function inside this file in the main.c file?

    I will have other questions when I progress but firstly I need to make this work.

    Thanks,

  2. #2
    Guest
    Guest
    For local files, you should use e.g.:
    Code:
    #include "header1.h"
    #include "../include/header2.h"
    ... depending on where the files to be included are relative to the file containing these statements.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    For non-header file you *need* to add the file to the project; this is the normal way to build the file.
    Including non-header file like "Initializer.c" is not normal.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  4. #4
    Registered User
    Join Date
    Dec 2010
    Posts
    113
    Thanks for the replies, I had already added the file to the project but I was assuming I also needed to adress it with including. When I deleted the include line it just saw the file and worked.

    Now I have got another question. Can I create my own header files? If so, what is the difference between creating a header file then including it and creating a file and just add to the project?

    Edit: Also I wonder if I need to use the function prototype if I get the function from another file? If I don't use it still works but I wonder if it is the legit way.
    Last edited by GokhanK; 05-26-2018 at 04:03 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code Blocks showing error in code! Don't know what's it.
    By kdushyant297 in forum C Programming
    Replies: 2
    Last Post: 09-08-2017, 09:59 AM
  2. Some help using Code::blocks !
    By Saurav Kalita in forum C Programming
    Replies: 1
    Last Post: 06-17-2012, 11:05 PM
  3. how to create a project in Code::Blocks?
    By jackson6612 in forum C++ Programming
    Replies: 2
    Last Post: 05-21-2011, 07:27 PM
  4. MS code::blocks
    By wart101 in forum C++ Programming
    Replies: 11
    Last Post: 12-14-2006, 11:59 AM
  5. Dev and Code Blocks
    By swgh in forum Game Programming
    Replies: 3
    Last Post: 04-07-2006, 07:21 PM

Tags for this Thread