Computer Science Canada

Help learning C and choosing a complier

Author:  php111 [ Wed Jan 02, 2008 10:04 am ]
Post subject:  Help learning C and choosing a complier

Hey everyone, Happy late new year.

I am actually interested in learning pure C. I am going to need some help with picking out a C complier for XP. At the beginning of the tutorial, I am not understanding, that might be because I never tried programming. I will post up the output and I will also post up the tutorial link. At some point someone probably read the tutorial. It is from the cprogramming board.


c:

#include
<stdio.h>

int main()
{
  printf( "I am alive!  Beware.\n" );
  getchar();
  return 0;
}


[edit by md]There, fixed that for you.

http://www.cprogramming.com/tutorial/c/lesson1.html

Author:  Mazer [ Wed Jan 02, 2008 10:14 am ]
Post subject:  RE:Help learning C and choosing a complier

You can try getting MinGW32. It's actually a crapload of compilers, but includes one for C. I'd also suggest that you make your include statement one line and PLEASE, this isn't very hard, use code tags.

Author:  php111 [ Wed Jan 02, 2008 10:20 am ]
Post subject:  Re: RE:Help learning C and choosing a complier

Mazer @ Wed Jan 02, 2008 10:14 am wrote:
You can try getting MinGW32. It's actually a crapload of compilers, but includes one for C. I'd also suggest that you make your include statement one line and PLEASE, this isn't very hard, use code tags.


This link is the closest I came to download it but I don't know which one to download it. I don't want to download the wrong one.

http://sourceforge.net/project/showfiles.php?group_id=2435


How do I make my statement of one line and how do I use tags? Yes I am sure I want to learn C. Then ASM.

Author:  md [ Wed Jan 02, 2008 11:27 am ]
Post subject:  RE:Help learning C and choosing a complier

Well, you would make your include one line by not putting a newline after #include, so it looks like so
c:
#include <stdio.h>


Code tags make your code look like it that line just there does; you can either use [code][ /code] (without the space in the second) or [syntax="c"][ /syntax] for C code specifically (again without the space). You put your code between the two bits in brackets, example (again... remove the space...)

[code]int main(int argc, char **argv)
{


}
[ /code]


[syntax="c"]int main(int argc, char **argv)
{


}
[ /syntax]

Author:  Mazer [ Wed Jan 02, 2008 4:41 pm ]
Post subject:  RE:Help learning C and choosing a complier

As for which version of MinGW32, I'll admit I had a hell of a time trying to figure it out myself last time. I suggest just going with the first download link on that page.

Author:  Junkhead [ Thu Jan 03, 2008 6:48 pm ]
Post subject:  Re: Help learning C and choosing a complier

I recommend you go download wxDevcpp, which includes the MinGW compiler by default. It's what I use to port my linux games over to windows, and it works wonderfully.

It also includes a visual form designer, so you can make cross-platform GUI programs with ease.

As for your code, I strongly recommend you keep your preprocessor statements (statements beginning with a #) on one line only, because the preprocessor works on a line-by-line basis (as defined in the C standard). If you don't follow the standard, your code might not be portable across different compilers (which comes to be a _big_ problem later on).

Hope this helps you out =)

Oh, here's a link to wxDevcpp by the way:

http://wxdsgn.sourceforge.net/

Author:  michaelp [ Thu Jan 03, 2008 7:23 pm ]
Post subject:  RE:Help learning C and choosing a complier

If you still plan on using MinGW and not wxDevcpp like Junkhead, here is the link you should download:

http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=240780

But wxDevcpp would probably be better, becaue it is an editor and compiler, AKA IDE.

Author:  md [ Thu Jan 03, 2008 7:28 pm ]
Post subject:  RE:Help learning C and choosing a complier

wxDevcpp seems like a poor way of learning the language. Forms and other GUI elements are library dependent and have nothing to do with the language. Likewise IDEs can very easily get in the way of learning.

If your going to learn anything I sugest finding a good syntax highlighting text editor (I use gedit on linux, there is surely something for windows) and a command line compiler. Then write some command like apps. GUIs are ALWAYS complicated and never a good thing for beginners to be doing.

Author:  Junkhead [ Fri Jan 04, 2008 3:36 pm ]
Post subject:  Re: Help learning C and choosing a complier

Ah, md is right, I was just thinking in terms of convenience though. I use gedit myself =) and gvim, which works great too (NOT recommended for beginners). On windows, it's harder to get a command line compiler set up and running though, since most windows dev tools are GUI based (just look at Visual Studio, for example). You might have to fiddle around with the $PATH variable (that's what it's called on Windows, right? Or was it %PATH...) to make sure your compiler is accessible via the command line.

On linux, that's never a problem though, since you can go to just about any linux computer with gcc installed and a text editor and start coding.

I mean, it's not like you _have_ to use the GUI portion of wxDevcpp, you could also just as easily go get Devcpp, which does not have the wxWidgets library bundled with it, but wxDevcpp seems less dated. All wxDevcpp does is offer a form designer if you ever want to use it, along with some wxWidgets libraries. You still get all the terminal coding goodness from wxDevcpp.

If you want to take md's approach, notepad++ is a good source code editor for windows, I'm pretty sure it has compiling options too, I'm unsure whether it's open source or not though.

Anyway, whatever option you choose, good luck!

Author:  md [ Fri Jan 04, 2008 5:59 pm ]
Post subject:  RE:Help learning C and choosing a complier

As for compilers; there is a great C compiler called TCC (Tiny C Compiler) that does have a windows port. I haven't ever tried it on windows myself, but it's wicked on linux.

Author:  php111 [ Sun Jan 06, 2008 5:23 pm ]
Post subject:  Re: Help learning C and choosing a complier

Hey, I was just quickly reading over this thread. Is MinGW made for Windows? I keep getting a connection dropped out.

Author:  Clayton [ Sun Jan 06, 2008 6:11 pm ]
Post subject:  RE:Help learning C and choosing a complier

Yes, yes it is.

Author:  php111 [ Sun Jan 06, 2008 7:43 pm ]
Post subject:  Re: RE:Help learning C and choosing a complier

Clayton @ Sun Jan 06, 2008 6:11 pm wrote:
Yes, yes it is.



hmm if it is for Windows then why is my connection dropping? Could it be for running p2p?

Author:  md [ Sun Jan 06, 2008 7:45 pm ]
Post subject:  RE:Help learning C and choosing a complier

what does it being a windows program have with your connection dropping?

I ask as a mere mortal who sees no connection whatsoever.

Author:  php111 [ Sun Jan 06, 2008 7:53 pm ]
Post subject:  Re: RE:Help learning C and choosing a complier

md @ Sun Jan 06, 2008 7:45 pm wrote:
what does it being a windows program have with your connection dropping?

I ask as a mere mortal who sees no connection whatsoever.


MinGW said my connection was dropping. I don't know why and it was the first time it happened.

Author:  Junkhead [ Mon Jan 07, 2008 11:05 am ]
Post subject:  Re: Help learning C and choosing a complier

That really does not make sense...Are you sure it's MinGW you downloaded? MinGW makes no network connections at any time, and has no network functionality built into it.

Could you perhaps post a screenshot?

Author:  Mazer [ Mon Jan 07, 2008 3:00 pm ]
Post subject:  RE:Help learning C and choosing a complier

I believe he's using the installer which uses a GUI to find and install the desired components for you.

But I don't know what to say about the connection dropping problem Sad

Author:  Junkhead [ Wed Jan 09, 2008 6:47 pm ]
Post subject:  Re: Help learning C and choosing a complier

Ah, in that case, it might be retrieving the install files over the internet, and maybe routing difficulties are causing the problem.

A screenshot would help quite a bit!

Author:  Mazer [ Wed Jan 09, 2008 11:25 pm ]
Post subject:  RE:Help learning C and choosing a complier

I just installed MinGW using that installer, if you get that network error message just hit retry and it should go. I had it pop up again later on but after hitting retry the installation completed and everything seems alright.

Author:  btiffin [ Tue Jan 29, 2008 12:07 am ]
Post subject:  Re: Help learning C and choosing a complier

For learnng; Check out Ch. Ch is an embeddable and interactive C/C++ from http://www.softintegration.com/

I've only tried the Standard Edition; but the Professional Edition is free for Academic Use. I use it for short experiments, exploring (ok, at my age ... it's more reminder than exploring) and verifying snippets before posting. I can't say I've used it for any large applications but I sure wish it was around when I had my first reads through K&R and Stroustrup.

Ch is more than just a C/C++ compiler, it's a true C shell. As a bonus, it comes with a nice subset of Unix commands on the Ch Windows console. The student/professional edition comes with a nice plotting subsystem.

Note; There is a free download Standard Edition, but Ch is a commercial effort. Standard is Free for Commercial or non-Comercial Use but is not redistributable (if my legalese is up to snuff). Multiple platforms.

Cheers,
Brian Tiffin

Author:  OneOffDriveByPoster [ Tue Jan 29, 2008 3:44 pm ]
Post subject:  Re: Help learning C and choosing a complier

There is also EiC, but IIRC, the included library is very buggy. I think it was printf or scanf. Everyone knows that glibc has a buggy scanf though.


: