User forums > Using Code::Blocks

Use of files containing source code

(1/2) > >>

richard7298:
Hi. I'm a complete newbie to CB and writing code. I'm mostly interested in running code for console applications.

I've copied and pasted into Notepad some simple code I found on the internet.  I've added this file to a Project. When I run debug there is a failure.  But, first of all, should the file containing source code, that I have added to the Project, come under "Others" or should it be saying "Sources"? Thanks. Rich

BlueHazzard:

--- Quote --- But, first of all, should the file containing source code, that I have added to the Project, come under "Others" or should it be saying "Sources"?
--- End quote ---
What? If you create a project it will create a .c or .cpp file. This files are automatically added to the virtual source folder in codeblocks. Your source files always have to end with .c or .cpp (or other common c++ file endings like .cxx). If the do not end with the right ending codeblocks does not know how to compile them...


--- Quote --- When I run debug there is a failure
--- End quote ---
Without exact error message no help.... http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

richard7298:
HI. OK, it's as I thought. My .txt file is under "Other" because it's not a source file.

Anyway, I've just got to figure out how I can take code from websites and get it into CB.  I just now created a new (blank) source file in CB.

EDIT: I added the .txt file to the Project. Then I copied and pasted the code from the .txt file into the new source file.  Then I un-added the .txt file. And the code runs OK. Whether this is how one should go about getting code into CB, I know not. But it did work. Rich

stahta01:
http://wiki.codeblocks.org/index.php/Creating_a_new_project

BlueHazzard:

--- Quote ---EDIT: I added the .txt file to the Project. Then I copied and pasted the code from the .txt file into the new source file.  Then I un-added the .txt file. And the code runs OK. Whether this is how one should go about getting code into CB, I know not. But it did work. Rich
--- End quote ---
Why not renaming the .txt file to a .c file?
source files are text files with a other ending...

Navigation

[0] Message Index

[#] Next page

Go to full version