Author Topic: Computer Science Contest... How to Set Up?  (Read 4710 times)

Offline arew264

  • Multiple posting newcomer
  • *
  • Posts: 22
Computer Science Contest... How to Set Up?
« on: February 17, 2008, 02:26:34 am »
I was at a computer contest today, and I had my laptop with me sitting next to the school laptop I have to program on. I did the example problem in C++ (all the contests are in Java), and wondered, "How should I be doing this in Code::Blocks?"

All the contest problems are made so they can be solved in under a page of code, and they should each have their own executable. If I compile pr21.cpp, I would like to get pr21.exe from MinGW. (all the code for problem 2.1 is in pr21.cpp)
I believe that the only way to get this sort of functionality would be either to add a build target for each source file and get them set up correctly (huge PITA) or create a blank project for each source file. Am I correct? Is there a better way to do it, like maybe some way of not using projects at all, but individual files?

How would Code::Blocks be used in a situation like this?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Computer Science Contest... How to Set Up?
« Reply #1 on: February 17, 2008, 08:24:38 am »
How would Code::Blocks be used in a situation like this?
As you said - a project per fail or a target per file. To achieve the same on the command line you would have to call the compiler the output's executable name, too. For C::B you do the same "in terms of a target". But. You can easily create a duplicate target and just change the output#s executable name. That's basically one click, another "OK" click, modify name and done.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Computer Science Contest... How to Set Up?
« Reply #2 on: February 17, 2008, 09:07:45 am »
Using Build->Compile current file (Ctrl-Shift-F9) would be more helpful. That way he doesn't need to create a project file, and the output file has the same name as the cpp (but exe instead, of course).

Pressing the gear button on the toolbar also calls Compile current file if all you have is a source file but no project opened. The play button runs it, and the gear + play button compiles it and then runs it.

Isn't that what you're looking for?

Offline arew264

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: Computer Science Contest... How to Set Up?
« Reply #3 on: February 17, 2008, 06:56:39 pm »
Yes, that's exactly what I'm looking for. You lose the convenience of having a project, but being able to easily create new files would be good.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Computer Science Contest... How to Set Up?
« Reply #4 on: February 17, 2008, 10:12:34 pm »
Yes, that's exactly what I'm looking for. You lose the convenience of having a project, but being able to easily create new files would be good.

Is that a question/suggestion? If so, just press Ctrl-Shift-N, or click the "New file" button on the toolbar, then "Empty file". You can use the File menu too.