Author Topic: Cannot change default source code when opening new console application  (Read 12030 times)

Offline sonicstrav

  • Single posting newcomer
  • *
  • Posts: 3
This comes up all the time:

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

I've changed the code under Setting>Editor>Default Code>C/C++ Source file and saved it but with a new project selecting a console app the same old 'Hello World!' stuff comes up again

How can I change the default code for this?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11726
    • Travis build status
File -> New -> Project -> right click on the template you want to modify -> Edit script....
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline sonicstrav

  • Single posting newcomer
  • *
  • Posts: 3
Hmm.....the above code doesn't appear in the script (when right-clicking on console application)  :?

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
The place for the template depends on your OS, but it seems you believe we hav the second sight.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6512
    • My Best Post
Hmm.....the above code doesn't appear in the script (when right-clicking on console application)  :?

Failed for me, also. Looks like Windows 7 security redesign type issue. I am using Windows 6.1 32 bit AKA Windows 7.

Looks like it was user error on my part; it works but not like I think it should; I never found a way to edit the c/cpp source code file thou the GUI.


The folder containing source code file to be edited on my machine:

 

My best guess on the files to edit are:
console.cbp
console.template
console-main-c.cpp
console-main-cpp.cpp


Destination under Windows 7 of modified files should be
(The folder is create/updated when the GUI is used to edit the script)

Code: [Select]
%APPDATA%\codeblocks\share\codeblocks\templates\wizard\console

I copied the missing files from
Code: [Select]
%ProgramFiles%\CodeBlocks\share\CodeBlocks\templates\wizard\console

The I edited the main.cpp file in the "cpp" folder. I then started Code::Blocks and it worked for me.

Tim S.


« Last Edit: June 20, 2010, 10:27:46 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sonicstrav

  • Single posting newcomer
  • *
  • Posts: 3
Thanks for your help, I'll try this  8)  :D
I am using Windows 7 ...sorry I wasn't specific enough
« Last Edit: June 21, 2010, 12:52:54 am by sonicstrav »

Offline WantCbPersonalized

  • Single posting newcomer
  • *
  • Posts: 6
Re: Cannot change default source code when opening new console application
« Reply #6 on: October 13, 2012, 10:32:38 pm »
Hello there,

I came to this topic because it is the most related with my problem. I also want to have a default code, so that i don't have to write every time #include... and using namespace std or ifstream fin(" .in/out"); .I don't know where I am doing wrong. I always start with ctrl shift n, a  empty file, and not project like many others. When I start a new file nothing appears, neither the Hello world thing, and I want to appear my default code. I know about the default code in Setting Editor Default code, but none of what I've written in there seems to appear ANYWHERE. What should I do?

Thank you in advance.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Cannot change default source code when opening new console application
« Reply #7 on: October 13, 2012, 10:42:39 pm »
What should I do?

Use "File -> New -> File... -> C/C++ source".
"CTRL+SHIFT+N" creates an empty file with no type.
The default code settings you have edited are either for C/C++ sources or headers.

Offline WantCbPersonalized

  • Single posting newcomer
  • *
  • Posts: 6
Re: Cannot change default source code when opening new console application
« Reply #8 on: October 13, 2012, 10:56:02 pm »
Thank you a lot! That worked! Sometimes CB is so tricky ;D