Announcement

Collapse
No announcement yet.

C Programming Question

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    C Programming Question

    I'm attempting to learn the C Programming language. At the moment I'm still in the "For Beginners" stage, and I have a quick question. If I write a C program for windows, can it be compiled for use with Linux?

    Is C programming the same for Linux as it is for Windows?

    #2
    Re: C Programming Question

    "C programming" is the same, the environments are not. But, as a beginning C programmer all you will likely do is write apps which use the stdio library to product programs which use text input and output. (stdin, stdout). Even then, you'd need to use cross platform compilers and API's which mask the differences between the file structure, kernels and libraries of the two systems. Later, when you start writing programs that present a graphical interface to the user you will need a cross platform GUI API.

    Here are some articles on the subject:
    http://blog.stoked-security.com/2009...-programs.html
    http://metamod-p.sourceforge.net/cro...for.linux.html
    http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux

    Installing Cygwin or MingW on Windows will take you half way to Linux. A better option would be to install VirtualBox and then run Kubuntu as a guest OS, and in it install gcc, build_essential package, and other dev tools, like Kate and Kdbg.

    For a cross platform API you could install the Qt4-SDK on both your Windows and on your Kubuntu guest OS (assuming you installed it) and then limit your C++ code to just the "C" examples in your lessons. C++ is just a superset of C and if you ignore its object capability you are, essentially, just programming in C. When you get into creating graphical interfaces for the user then the POWER of the Qt4 cross platform API becomes apparent. Since KDE4 was built using Qt4 you can understand the power it has. I used Qt4 for several years before I retired. I wrote my code on Linux using Kate and Kdbg because it was up to five times faster than using MSVSC 6.0. Then I'd port my source code to Windows and recompile under MSVS and deploy. I used compiler defines to select platform dependent database code, etc...

    The equal or better equivlient of MSVSC in Kubuntu is qtcreator, which is in the repository. For windows you can download it from here. An excellent support forum is here.
    "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
    – John F. Kennedy, February 26, 1962.

    Comment


      #3
      Re: C Programming Question

      Full Circle Magazine (free download) ran a series a while ago about using C on Ubuntu. Begin here: http://fullcirclemagazine.org/issue-17/
      "A problem well stated is a problem half solved." --Charles F. Kettering
      "Sometimes the questions are complicated and the answers are simple."--Dr. Seuss

      Comment


        #4
        Re: C Programming Question

        That was a 404! link. Here is the PDF: http://fullcirclemagazine.org/downlo...ager.php?id=98
        "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
        – John F. Kennedy, February 26, 1962.

        Comment


          #5
          Re: C Programming Question

          I'm just downloading collecting those magazines but I noticed there's no issue 21 pdf file available, I just got a 404 error on screen. I wonder if someone has a copy...
          Multibooting: Kubuntu Noble 24.04
          Before: Jammy 22.04, Focal 20.04, Precise 12.04 Xenial 16.04 and Bionic 18.04
          Win XP, 7 & 10 sadly
          Using Linux since June, 2008

          Comment


            #6
            Re: C Programming Question

            That's because there is no January, 2009 issue.
            "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
            – John F. Kennedy, February 26, 1962.

            Comment


              #7
              Re: C Programming Question

              Really? Then what happened to Program in C – Part 5? At least I could download the Italian version but it doesn't mean I'm really capable of understanding the contents of it...
              Multibooting: Kubuntu Noble 24.04
              Before: Jammy 22.04, Focal 20.04, Precise 12.04 Xenial 16.04 and Bionic 18.04
              Win XP, 7 & 10 sadly
              Using Linux since June, 2008

              Comment


                #8
                Re: C Programming Question

                Don't know... but... if you look in the far right column, under the "Post Archives" section of http://fullcirclemagazine.org/ you will notice that Jan, 2009 is missing.

                Neither that site nor that article was too impressiv, for your needs.

                A simple Google search for "programming C++ linux" will turn up lots of sites, like these:

                http://www.cplusplus.com/forum/beginner/

                http://www.techbooksforfree.com/linux.shtml

                http://www.mindview.net/Books/TICPP/...ngInCPP2e.html
                "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                – John F. Kennedy, February 26, 1962.

                Comment


                  #9
                  Re: C Programming Question

                  Yeah, I thought fullcircle's articles would be quite basic but it was an incentive for some fearful people that fear programming might make their PC's crash or go directly to the trash can because they "created" a virus or something like that, to learn more about it and not fear something awful will ever happen if they make a couple of mistakes in the process.

                  (How curious it is to see that they devoted more articles or article parts to Python than to C itself...)
                  Multibooting: Kubuntu Noble 24.04
                  Before: Jammy 22.04, Focal 20.04, Precise 12.04 Xenial 16.04 and Bionic 18.04
                  Win XP, 7 & 10 sadly
                  Using Linux since June, 2008

                  Comment

                  Working...
                  X