Writing and compiling a C program under Windows XP?

This is an absolute question for beginners, but in the last podcast I understand that the question is not too new.

I have 0 programming experience and I want to learn C, so I am starting a K & R book. I am using a laptop for Windows XP, and I plan to use Notepad ++ for writing and Code :: Blocks for compilation.

Here is my question: as soon as I wrote the "hello world" program in Notepad ++, how to save, compile and run it?

Change and a new question: when I create and run from Code :: Blocks, I get a window with the message "hello world". It remains open until I close it manually. However, when I double-click the .exe file, the prompt just blinks and disappears, why?

Many thanks,

Jd

Edit: I am going to use Code :: Blocks as an IDE as recommended here.

+6
c
source share
10 answers

You should be able to write C in Visual Studio. Of course you could in older versions of the IDE. Just create source files with the extension .c.

You should be able to create and run code from Visual Studio.

+6
source share

Save it as a .c file. And you can use the MinGW compiler to compile the file into a .exe file. But since you have Visual Studio, you must use this compiler.

+9
source share

If you are just learning to program, I would not recommend starting with C. C, which still has its place today, but there are much simpler languages ​​in which you can learn the basic syntax and technique. As far as I understand, there are not so many C newbies. You can, however, be hired by a novice java, C #, VB, ruby, or python programmer, and people will pay you for the training. Then, when you have a solid foundation in structure and technique, you can get closer to metal with C.

Only my two cents, even if this is not the answer to your question.

+5
source share

If you DO NOT want to use visual-studio, you can try something like codeblocks that allows you to use the VS compiler ... it is much simpler and easier if you are just getting started.

+3
source share

As other posters have noted, Visual Studio can be a little overwhelming for beginners - lots of options and a lot of fluff required to get a simple “Hello World” at the door.

I personally recommend the Bloodshed Dev-C ++ IDE for beginners. This is no longer processed (so you get a stable, not a beta version), but it’s very easy to switch from entering the first program to compiling it and running it. If you stick with Windows, you'll end up with Visual Studio, but Dev is a great oriental place to start.

You can edit files in Visual Studio (this is an IDE, an integrated development environment and should contain absolutely everything you need to write a program), but you will notice that most programmers use external editors, such as Notepad ++, because they offer some nice features that you usually don’t get in the IDE’s embedded environment. Don't worry about this at the moment, but try an external editor, such as n ++, when you are more familiar with the rest of the process.

Oh, and C can in no way be described as "covering key principles in a small language." It definitely covers the “key principles” - it was used for everything under the sun, but is absolutely huge. Whether it is suitable for a beginner these days is subject to discussion; this will definitely give you a good experience, but it will not be the easiest way to start.

Edit: CodeBlocks is more modern and still under development, so it might be better to get started than DevC ++ http://en.wikipedia.org/wiki/Codeblocks

+2
source share

If you copy the code from K & R, you need to add a system ("pause"); before you finish main () and make sure you save the file with .c

int main ()
{
printf ("Hello world \ n");

system ("pause");
return 0;
}
I am also starting, hope this helps.

+2
source share

To get started, I recommend creating a project, editing and compiling in VC. Then start exploring which VC commands actually run under its covers (I think it will be something like the "output" tab). You can do all this on the command line, although Windows is not the most friendly programmer environment.

+1
source share

just in case you haven’t understood yet, for example, visual studio, code :: blocks also has a built-in editor. You do not need to write in notepad ++ (unless, of course, you prefer npp as an editor)

+1
source share

Here is an opinion from someone who has used C for many years in biomedical research: image processing, data crunching. IMHO, C is a serious intellectual achievement, probably the best distillation of intent in syntax. I would learn C again if I started, even if I just learned to think.

However, I did not even try to program C in MS. (All my work was on Suns and SGI.) To avoid the overhead mentioned in other answers, I switched to Python on MS XP / cygwin. However, I often miss the expressive syntax, and I miss how bits and values ​​are stored in memory. Note that even with Python, the background end is C, and custom extensions are encoded in C. Thus, if I wanted to remake the image processing code for Python, I would probably end up writing C. In the end.

Sorry that MS places such a burden on writing about the leanest language ever invented. (By the way, as for editors, my personal choice is vim (like gvim), not IDE.) (Have you thought about creating a Linux box? How much does it cost to say these days: UNIX without the cost of workstations.)

+1
source share

Try a simpler compiler like * nix gcc. Visual Studio C ++ adds many MS extensions to code files.

0
source share

All Articles