Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: richard7298 on October 25, 2018, 09:17:20 pm
-
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
-
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"?
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...
When I run debug there is a failure
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
-
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
-
http://wiki.codeblocks.org/index.php/Creating_a_new_project (http://wiki.codeblocks.org/index.php/Creating_a_new_project)
-
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
Why not renaming the .txt file to a .c file?
source files are text files with a other ending...
-
Changing the extension from .txt to .c worked perfectly. Changing the file extension was the first thing I thought about, but because only the name of the file was highlighted when I clicked on "Rename" I thought I could not change the extension. Anyway, I'm now sorted. Thanks. Rich