r/learnprogramming • u/Roughneck979 • 1d ago
Trying to learn c
What is an easy to use compiler to use to get started.
Got a book to learn and they use code::block in book, tried and it seems to not be building. Then tried MS visualization studio and was lost. Please help
6
u/serge-mv 1d ago
Both of those are popular and good IDEs. If you are having trouble with them, then you probably should try and figure out why things aren't working as expected. Changing an IDE won't really help you here. Dealing with problems like these is part of the job.
1
u/Roughneck979 1d ago
Well i typed the example code in codeblock and hit the build and it did nothing, tried run and it said it wasnt built yet, clicked yes and still just sat there and nothing happened, maybe installed wrong?
2
u/serge-mv 1d ago
There are really many reasons why this could happen. One, the example was not complete in itself and required a header that wasn't specified. Very common problem. Two, you didn't create the project properly or created it for incorrect language. Three, you didn't specify correct compiler. There could be other problems as well.
What you should if you are stuck, try to search for more web tutorials for C, and also for code::blocks. They have comprehensive manual on the IDE that you can check. You could also ask for specific help with your problem.
1
u/Roughneck979 1d ago
Thanx for the input i will seek more tutorial/input. But good to hear that the codeblock used in book seems common/popular
1
u/serge-mv 1d ago
I think I know what is happening. Code:Blocks by default opens a new terminal where it directs the standard out. That window will close very quickly and you won't be able to see anything. Here is what you can do immediately.
Take your example as is, and right above "return 0;", which you probably have, add getchar();
which will stop executing the program until you type a character and hit enter. This way, you will be able to see it.
1
u/iOWIIPZJ51ucF2H 1d ago
you probably downloaded the codeblocks installer without mingw bundled. check settings -> compiler -> toolchain executables, the path is almost certainly empty. grab the installer with mingw-setup in the filename so gcc actually comes with it.
4
u/Rythim 1d ago
Probably depends on preference. I find code::blocks or using the command line easiest.
Note though: code::blocks and Visual Studio are IDE. Not compilers. If they aren't doing anything when you press build I wonder if you somehow installed them without setting up a compiler?
1
u/Roughneck979 1d ago
Thank you for input i will uninstall and check my installation again for potential issues
3
u/abccbabcac 1d ago
vs code with c/cpp extension is pretty simple for new learners:
https://code.visualstudio.com/docs/languages/cpp
however, my usual approach is command line based rather than using an ide. nvim for editing files and gcc for compiling.
3
1d ago
[removed] — view removed comment
1
2
1
u/Merry_Janet 1d ago
Clang or MSCV?
If you mean development environment, VS Code is free.
1
u/Roughneck979 1d ago
Clang? Mscv? Dont know what those are. Sorry
2
u/Round_Thanks_2780 1d ago
Those a compilers.
They read your code and translate it to machine code.Visual Studio and CodeBlocks run them when you press the "build" button.
2
u/Round_Thanks_2780 1d ago
Clang is mainly used for Apple + Linux development, while MSCV is for Windows development.
1
1
u/Mediocre-Pumpkin6522 1d ago
Compiler front ends. GCC is the GNU Compiler Collection, and Clang takes a different approach but is compatible with GCC. Microsoft Visual C++ is not particularly compatible with either. code:blocks can use any of them but needs to be configured.
If you chose the MinGW install it should use gcc. If you didn't there may not be a compiler. If you installed MS Visual Studio you may have to install the C/C++ work load.
1
u/Roughneck979 1d ago
Ok i didnt install ANY of the workload things so that is probably where i goofed on visual studio
1
u/Merry_Janet 1d ago
Yeah, with VS Code you need to install a C/C++ compiler.
paste "vscode c compiler" into google without quotes and follow the 3 steps.1
u/Mediocre-Pumpkin6522 1d ago
iirc you get C# default. I remember being surprised by something I had to explicitly install but it's been a while.
1
u/GobblerOfFire 1d ago
It fully depends on what you’re comfortable with. I use nvim and gcc for compiling. All free. But some people want the AI autocomplete stuff so they want vs code. I have only ever used nvim and some VS code use but I don’t like all the distracting bloat / million things to click on and I’m privy to command line. To each their own
1
u/Roughneck979 1d ago
I know some basic java and am familiar with editing xml files but that is about the extenet of it
1
1
u/marrsd 1d ago
I guess you're running Windows. I'd honestly just use a terminal, a compiler (run from the terminal), and a basic text editor with syntax highlighting and decent navigation. I think they're much easier to get started with. Once you need debugging, use a dedicated debugger. Then you don't have to worry about learning the IDE or how it integrates debggers, compilers, linkers, and the like.
I haven't run Windows in ages, so I'm not going to be much help with specifics. My advice would almost certainly be out of date.
1
u/my_password_is______ 1d ago
codeblocks is just a fancy editor
but you can download the version that comes with a compiler
https://www.codeblocks.org/downloads/binaries/
you want
codeblocks-25.03mingw-nosetup.zip
1
u/Erdem_PSYCH 17h ago
try cs50x. cource from harvord. It is hard but you learn comanline and such and don't need much instolation.
•
u/MikeIsBoi 49m ago
I would suggest to use CLion by Jetbrains, I think it is free now for personal non comertional use. It comes with ninja build system already bundled so no need to set anything up. I used it when I was learning programming on windows.
I would discourage you from using Visual Studio and MSVC since they are kinda garb.
Later if you get more advanced I would suggest switching to Linux and using CMake.
I personally use neovim and build my application using CMake on my Linux desktop.
-1
u/Dazzling_Music_2411 1d ago
Right, so you didn't install the compiler, and you're wondering why it's not compiling!
This is why it's important to install (and experiment with) the compiler way before you install any IDE.
Funny how in this age of information and AI and what have you, things that used to be considered as blatantly OBVIOUS seem to be unfathomable mysteries now.
1
u/Roughneck979 19h ago
Im new to this. The book i have said that code block came with a compiler so i assumed visual studio was similar, didnt want to install a bunch of things i didnt necessarily need. So please take your attitude somewhere else.
0
u/Dazzling_Music_2411 19h ago
Don't shoot the messenger, buddy, you missed something that would have been ridiculous to miss in the past, or if you had followed a sensible progression. It's not "attitude" to point that out.
It might not even be your own fault - it's not the first time I've seen someone make this mistake - there is a social problem at large with people thinking they're entitled to not making an effort. I blame AI, mainly.
2
u/my_password_is______ 17h ago
It's not "attitude" to point that out.
its not attitude to point it out, but the way you point it out shows you definitely have an attitude
5
u/NomaTyx 1d ago
You're thinking of an IDE. A lot of people like VS Code, but I quite like CLion, which is free for non-commercial use.