Using Debian 11 For C Using Code Blocks {Solved}

Alexzee

Well-Known Member
Joined
Jun 1, 2019
Messages
3,591
Reaction score
1,911
Credits
21,200
Code Blocks is new to me and I'm following this tutorial to learn.

When additional code is added to what has already been written (see the screenshot) does a new file have to be created for the build to run and show the results?

OR> Can I just add an additional code before build> build and run?
Code:
printf("I am learning C today");

Is there a way to make that blinding white background any other color?
 

Attachments

  • Code Blocks.png
    Code Blocks.png
    224.7 KB · Views: 95
  • Colors.png
    Colors.png
    329.9 KB · Views: 101


When additional code is added to what has already been written (see the screenshot) does a new file have to be created for the build to run and show the results?

OR> Can I just add an additional code before build> build and run?

You can use the same file, just make sure you you save the changes before running it. I always do a backup from time to time,
because you never know if what you change might break something.

Is there a way to make that blinding white background any other color?

There are at least two ways to do this. Usually your terminal/console has a preferences or settings tab where
you can change the background and text colors.

You can also do this in your C code.

#include <stdio.h>
// ANSI escape codes for text colors
#define ANSI_RESET "\x1b[0m"
#define ANSI_RED "\x1b[31m"
#define ANSI_GREEN "\x1b[32m"
#define ANSI_YELLOW "\x1b[33m"
#define ANSI_BLUE "\x1b[34m"
#define ANSI_MAGENTA "\x1b[35m"
#define ANSI_CYAN "\x1b[36m"

int main() {
printf(ANSI_RED "This text is red!\n" ANSI_RESET);
printf(ANSI_GREEN "This text is green!\n" ANSI_RESET);
printf(ANSI_YELLOW "This text is yellow!\n" ANSI_RESET);
printf(ANSI_BLUE "This text is blue!\n" ANSI_RESET);
printf(ANSI_MAGENTA "This text is magenta!\n" ANSI_RESET);
printf(ANSI_CYAN "This text is cyan!\n" ANSI_RESET); return 0; }
 
Last edited:
Alexzee asked:
Is there a way to make that blinding white background any other color?
If you are using firefox, the addon: "Dark Background and Light Text", would normally reverse the white. Additionally, one can choose the Dark theme in firefox. Other browsers may have similar addons.

Also, that first return0 in the c code is unnecessary.
 
Other browsers may have similar addons.

I believe Dark Reader and Sauron are fairly universal, meaning Chrome and Firefox support.

For no good reason, I use one in Chrome and the other in Chromium. I literally have no good reason for doing so and should standardize for simplicity's sake.
 
Thanks
You can use the same file, just make sure you you save the changes before running it. I always do a backup from time to time,
because you never know if what you change might break something.



There are at least two ways to do this. Usually your terminal/console has a preferences or settings tab where
you can change the background and text colors.

You can also do this in your C code.

#include <stdio.h>
// ANSI escape codes for text colors
#define ANSI_RESET "\x1b[0m"
#define ANSI_RED "\x1b[31m"
#define ANSI_GREEN "\x1b[32m"
#define ANSI_YELLOW "\x1b[33m"
#define ANSI_BLUE "\x1b[34m"
#define ANSI_MAGENTA "\x1b[35m"
#define ANSI_CYAN "\x1b[36m"

int main() {
printf(ANSI_RED "This text is red!\n" ANSI_RESET);
printf(ANSI_GREEN "This text is green!\n" ANSI_RESET);
printf(ANSI_YELLOW "This text is yellow!\n" ANSI_RESET);
printf(ANSI_BLUE "This text is blue!\n" ANSI_RESET);
printf(ANSI_MAGENTA "This text is magenta!\n" ANSI_RESET);
printf(ANSI_CYAN "This text is cyan!\n" ANSI_RESET); return 0; }
Thanks dos2unix.-:)
I'll look in the terminal first and if that doesn't work for me I'll change it in the C code.

I want to change this line to BLUE-
Code:
#define ANSI_BLUE "\x1b[34m"

Do I just need to remove the # sign in front of the argument?
 
Last edited:
Alexzee asked:

If you are using firefox, the addon: "Dark Background and Light Text", would normally reverse the white. Additionally, one can choose the Dark theme in firefox. Other browsers may have similar addons.

Also, that first return0 in the c code is unnecessary.
I mean changing the background in the program I'm using "Code Blocks".
See the attached file where my mouse is in the all white space in the program.
That where I want to get rid of the white background in the build log.
 

Attachments

  • Mouse.png
    Mouse.png
    206.2 KB · Views: 89
Last edited:

Attachments

  • SRC Config.png
    SRC Config.png
    55.9 KB · Views: 82
After following these instructions:

The dark theme (obsidian) was added (see attached file screenshot) however; the build log is still blinding white!
UGH, very frustrating.
 

Attachments

  • Color Change.png
    Color Change.png
    356.2 KB · Views: 79
Last edited:
I was able to pull up a build that I already did and that had the dark background so that's good.
See screenshot/attached file:-

Anyone using Code Blocks and knows how to create a new empty file and make that dark?
 

Attachments

  • Dark CB.png
    Dark CB.png
    228.2 KB · Views: 85
@JasKinasis do you use Code Blocks?
Not for many, many years. I’ve been using Vim and make, cmake, or qmake in the terminal for donkeys years. Next time I’m on my laptop, I’ll install code::blocks and will have a look at it.
The dark theme always used to work fine for me. I don’t remember having any problems with parts of the IDE still being bright.
 
I knew about Vim. Went through the Vim tutorial in the terminal a few years ago.
Didn't know I could use cmake or qmake to write code, thanks.

There's a difference I've learned. I'm reading and learning C so this is all new to me.
Reading the Manual here:

Can you recommend a website or book to assist with learning C programming?
I don't use cmake and qmake for writing code. I use vim in the terminal for writing code.
Make, cmake and qmake are the main build systems I use when I'm in the terminal.

So for example:
If I'm creating something simple, in C or C++ - I'll use plain old make.
If I'm doing something that's a bit more complicated, that requires a lot of external libraries, or that has a lot of separate modules in it - I'll use cmake.
If I'm creating a QT based project using C++ - I'll use qmake.


And I use cgdb (ncurses frontend for gdb) as my debugger.

So instead of using an IDE where everything is contained in an all singing, all dancing GUI - I just use all of the tools separately.
But I always use tmux to manage my terminal sessions. So I'll have a tmux session running with a terminal containing vim and another terminal undeerneath which I'll use for running builds, or debugging. Tmux uses vim like keybinds, so switching between vim and the spare terminal is pretty simple - so in a way tmux is my IDE.

WRT learning C - I highly recommend "Effective C" by Robert C Seacord, published on No Starch Press.
That book is recent and comprehensively covers the modern C programming language, it's suitable for complete beginners and it includes information about best practices for professional programmers.
So it will give you a much better knowledge of modern C, without falling into the trap of using outdated/bad practices that are found in many older C textbooks.

And it covers buildling on Linux using gcc, clang, or an IDE like Visual Studio Code. If you're already using Code::Blocks - you may as well stick with that. The book doesn't cover using Code:::Blocks - but one IDE is going to be pretty much exactly the same as any other. They won't be exactly the same, but they all provide similar funcitonality to you as a user.

WRT Videos - I have no idea. I'm old-school. Ebooks are about as modern as I get. But I prefer physical books.
 
I found the book "Effective C" by Robert C Seacord, thank you, JasKinasis. :)

As this is new to me, until you told me I had no idea that one IDE is pretty much the same as any others.

I'll stick with Code Blocks unless there is a reason for me to move to Visual Studio Code.
 
Aren't we supposed to be against sharing links to pirated, copyrighted materials here?
Because the link posted by Alexzee is blatantly a link to an illegal ebook sharing site.

Heh, I'd already removed it when I saw this comment. It's safe to assume that @wizardfromoz thought that it was a free eBook.

So, no, @Alexzee don't add the book to that thread. If you already have, please remove it.
 
The link in post #13 may not be a free ebook either. :oops:
 
The link in post #13 may not be a free ebook either. :oops:

Yup. Sure enough, it was. It's available to purchase and I see no evidence that the author allowed the uploaded file to be shared without remuneration.

Thanks for pointing it out. Alas, I don't notice everything.
 
I'm sure Alex didn't mean to break any rules. I'd bet I've posted many links before to things I shouldn't also... Google-searching info for a topic here and posting what I find. It's kinda easy done without thinking about it.
 

Members online


Top