Tuesday, July 14, 2009

How do I practice C programming at home?

Hi,





I'm taking a basic programming class since I'm an electrical engineering undergrad. I have programming classes every Monday and Wednesday, however, for the type of learner that I am, I need to do a lot of practice. I asked my professor how I could work at home, but instead, he suggested that I just come into the lab to work my problems out. I live pretty far from school so I don't really want to do that. I mean, it's regular C language, so I'm positive I could do it on my laptop running XP media center '05.





I don't know the info you need to answer the question, but here are a few facts.





-We're using the OS Red Hat Linux


-We use text editor to program


-We use something called terminal that looks a lot like MS-DOS





I've read that I can use notepad and MS-DOS to do the same things, but I couldn't figure it out. I hope I gave enough info. I'll add on more if you do need to know some extra.

How do I practice C programming at home?
In linux


vi a.c


write code


type gcc a.c


run a.out


in windows


download turbo c compiler and use it to compile the code.
Reply:The Link below tells you how to write an ANSI C program using C++ in 2005 Visual Studio.
Reply:There will be some differences in the libraries available to a Windows Programmer and a Unix/Linux programmer. For example, Windows does not have a "fork()" function (as far as I know). Unix/Linux does not have a conio.h library.





I would suggest trying an install of Linux on your home computer as a dual boot system. While there are very good C/C++ compilers available for Windows, Unix/Linux is pretty much the standard for techies. If you're going into engineering, you will probably need to learn Unix in one form or another.





Also, Linux and Unix are pretty good about following standards. The Gnu compiler is pretty universal on all Unix like systems, like Linux and Mac OSX.





Any Linux distro will do. For a newbie, try using Ubuntu or Kubuntu. You will need to select development packages during the installation. You can use a fancy IDE like eclipse or Kdevelop. However I personally prefer to use EMACS while some folks I know prefer to use VI. In any case, these editors are geared more for programmers.





The Idea of using Notepad to edit code sounds excruciating. Notepad is not meant for programming. It doesn't have a C mode that automatically indents your code for readability. It doesn't have macros that make programming easier. It is simply a very bare bones editor.





Another option is to download the Cygwin toolkit. Cygwin is a port of the Gnu compiler for Windows and it includes a bunch of standard Unix libraries ported to Windows. It also includes a bash shell (the thing that's like the MSDOS prompt).





Learn the shell. Bash is much more powerful than the DOS shell and if you go into engineering and programming, you'll find it handy to know. I don't know how Windows programmers are able to program without it.





For an editor, I personally recommend EMACS. It has been ported to Windows. But for any really large projects, you'll want an IDE like eclipse.





Whatever you do, do NOT go out and buy Microsoft Visual C++ or C#. They are NOT standard and are not easily ported to Unix (where your schoolwork will be graded). As I said, as an engineer, Unix will probably be a requirement.
Reply:All you need to write C at home is a text editor and a compiler. The text editor can be as simple as notepad or as slick as the Eclipse integrated development environment. For a compiler, google 'c compiler' and you'll get a whole list of freebies.





Something else you might be interested in would be Microsoft's Visual C# (pronounced "C Sharp"). You can download Visual C# Express for free from their website, which will include a compiler and -- in my opinion -- the slickest of all integrated development environments, Microsoft Visual Studios 2008. From there, you can build Windows applications, web applications, XAML browser applications, web services -- all kinds of stuff.





Best of luck.








Edit -- to "Mike D"...





I find it hilarious that a professional programmer -- who uses EMACS, no less --can't figure out know how a Windows programmer can function without BAsh .





See, to me, one look at BAsh and emacs makes me have flashbacks from when I was programming Pascal on Unisys ICON machines in a QNX environment back in high school... Kinda makes me want to put a gun in my mouth, frankly.





I mean, say what you will about Microsoft, but Visual Studio sets the gold standard for integrated development. Open your mind, give it a tumble, and see what it's like writing code in the 21st century. You might just like it.


No comments:

Post a Comment