C

Discussion in 'C Programming' started by abi, Oct 23, 2007.

  1. abi

    abi Guest

    hi,
    i have a c program in notepad. How to convert it or how to compile
    it?
     
    abi, Oct 23, 2007
    #1
    1. Advertising

  2. abi

    Guest

    abi wrote:
    > hi,
    > i have a c program in notepad. How to convert it or how to compile
    > it?


    You can compile with mingw-gcc for win32, like this
    >> gcc -Wall -c abi_c.c [Enter]

    This will compile your c program, and generate one corresponding
    object file if your program has no error.

    OR

    Create a project with VS2005, and build it.
     
    , Oct 23, 2007
    #2
    1. Advertising

  3. abi

    user923005 Guest

    On Oct 22, 6:13 pm, abi <> wrote:
    > hi,
    > i have a c program in notepad. How to convert it or how to compile
    > it?


    1. Install a compiler
    2. Read documentation for compiler referenced in step 1
    3. Follow the instructions.

    If you install gcc, then you would save your c program to a file such
    as test.c and then using gcc you would do this:

    dcorbit@DCORBIT64 /c/tmp
    $ gcc -W -Wall -ansi -pedantic test.c

    dcorbit@DCORBIT64 /c/tmp
    $ ./a
    Hello world!

    dcorbit@DCORBIT64 /c/tmp
    $ cat test.c
    #include <stdio.h>

    int main(void)
    {
    puts("Hello world!");
    return 0;
    }

    dcorbit@DCORBIT64 /c/tmp
    $
     
    user923005, Oct 23, 2007
    #3
  4. abi said:

    > hi,
    > i have a c program in notepad. How to convert it or how to compile
    > it?


    "This is the big hurdle", as Brian Kernighan rightly said. Everything else
    in C is relatively simple by comparison.

    1) Save the file somewhere on your filesystem, and preferably somewhere
    that you can find easily in a console window! (See below.) Use a .c
    extension. Given the nature of the text editor you have chosen, you may
    need to use quotes to stop the editor from slapping a .txt extension onto
    the name. For example, if your program is:

    #include <stdio.h>
    int main(void)
    {
    puts("Hello, world!");
    return 0;
    }

    then you might want to specify the filename as "hello.c" (including the
    quotes). The editor will - I hope - take the quotes as a hint not to do
    something stupid. As far as your filesystem is concerned, the filename
    will be taken as hello.c - i.e. without the quotes.

    2) If you don't have a C compiler installed, install one. You can find a
    list of free C compilers here:

    http://www.cpax.org.uk/prg/portable/c/resources.php#FreeCompilers

    3) Consult the compiler's documentation to discover how to tell that
    compiler to compile the C file you saved earlier. Try to insist that it
    places the resulting program (if any - i.e. if you didn't make any serious
    mistakes in your program) in roughly the same place that you stored the
    source file.

    4) Open a console window (if you haven't already) and navigate to the right
    place on your filesystem.

    5) Run the program by typing its name.

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
     
    Richard Heathfield, Oct 23, 2007
    #4
  5. abi

    Road Tang Guest

    Road Tang, Oct 23, 2007
    #5
  6. abi

    user923005 Guest

    user923005, Oct 23, 2007
    #6
  7. user923005 said:

    > On Oct 22, 6:27 pm, Richard Heathfield <> wrote:
    > [snip]
    >> 2) If you don't have a C compiler installed, install one. You can find a
    >> list of free C compilers here:
    >>
    >> http://www.cpax.org.uk/prg/portable/c/resources.php#FreeCompilers

    >
    > Don't forget Watcom C:
    >
    > http://www.openwatcom.org/index.php/Download


    Thank you. Duly added.

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
     
    Richard Heathfield, Oct 23, 2007
    #7
  8. abi

    Richard Guest

    Richard, Oct 23, 2007
    #8
  9. abi

    santosh Guest

    abi wrote:

    > hi,
    > i have a c program in notepad. How to convert it or how to compile
    > it?


    Convert it to what?

    First save your program to a file. Then invoke your system's C compiler
    and pass this file as it's source file. Your compiler and it's support
    programs must be in your executable search path.
     
    santosh, Oct 23, 2007
    #9
  10. abi

    santosh Guest

    Richard Heathfield wrote:

    > abi said:
    >
    >> hi,
    >> i have a c program in notepad. How to convert it or how to
    >> compile
    >> it?

    >
    > "This is the big hurdle", as Brian Kernighan rightly said. Everything
    > else in C is relatively simple by comparison.


    <snip>

    I personally found this to be the smallest hurdle in learning C.
     
    santosh, Oct 23, 2007
    #10
  11. abi

    Richard Guest

    santosh <> writes:

    > Richard Heathfield wrote:
    >
    >> abi said:
    >>
    >>> hi,
    >>> i have a c program in notepad. How to convert it or how to
    >>> compile
    >>> it?

    >>
    >> "This is the big hurdle", as Brian Kernighan rightly said. Everything
    >> else in C is relatively simple by comparison.

    >
    > <snip>
    >
    > I personally found this to be the smallest hurdle in learning C.


    Yes, but like that rubbish about debugging being twice as hard as
    writing it right in the first place, if it comes from the mouth of a
    "great" it must be true according to some.

    Compiling a simple program is, of course, easy to anyone capable of
    reading. Understanding C and designing programs to utilise its core
    strengths is not.
     
    Richard, Oct 23, 2007
    #11
  12. santosh said:

    > Richard Heathfield wrote:
    >
    >> abi said:
    >>
    >>> hi,
    >>> i have a c program in notepad. How to convert it or how to
    >>> compile
    >>> it?

    >>
    >> "This is the big hurdle", as Brian Kernighan rightly said. Everything
    >> else in C is relatively simple by comparison.

    >
    > <snip>
    >
    > I personally found this to be the smallest hurdle in learning C.


    It has rightly been said that the distance between 0 and 1 is greater than
    the distance between 1 and 1000. (Your mileage may vary. Mathematicians
    need not apply. May contain nuts.)

    When I first learned C, I did so by taking a 13-week course. We were given
    quite a few days of classroom stuff before we were let loose on a
    computer. Our first task was "hello, world". We didn't have to install the
    compiler - that had already been done for us, thank heaven.

    One of the people in the class (a very promising student, it seemed to the
    rest of us) got quite a few (I think it was 13) compilation errors. He got
    up and walked out of the lab, and we never saw him again.

    We all know that he's probably made just one mistake, or possibly two -
    maybe a missing semicolon, maybe a 0 instead of a ), or whatever. Had he
    fought his way over that hurdle, I'm sure he would have made a perfectly
    good C programmer. But it was too big a *perceived* hurdle for him.

    I stand by my original statement. Compared to the challenge of getting
    "hello world" up and running, *especially* if nobody has been kind enough
    to install a compiler for you, the rest of C is relatively simple.

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
     
    Richard Heathfield, Oct 23, 2007
    #12
  13. abi

    santosh Guest

    Richard Heathfield wrote:
    > santosh said:
    >
    > > Richard Heathfield wrote:
    > >
    > >> abi said:
    > >>
    > >>> hi,
    > >>> i have a c program in notepad. How to convert it or how to
    > >>> compile
    > >>> it?
    > >>
    > >> "This is the big hurdle", as Brian Kernighan rightly said. Everything
    > >> else in C is relatively simple by comparison.

    > >
    > > <snip>
    > >
    > > I personally found this to be the smallest hurdle in learning C.


    <snip>

    > I stand by my original statement. Compared to the challenge of getting
    > "hello world" up and running, *especially* if nobody has been kind enough
    > to install a compiler for you, the rest of C is relatively simple.


    In practically every C course I can think of, a ready to use compiler
    and environment were provided. If someone is going to learn C at home,
    then he ought to familiarize himself with the basic usage of
    computers, (manipulating files, installing programs etc.), before
    attempting to learn C.

    In summary what you say would be true only in two cases, (I can think
    of):

    1. Attempting to learn C before learning the basics of using
    computers.
    2. Attempting to write your first program before getting the basics of
    C syntax down pat.
     
    santosh, Oct 23, 2007
    #13
  14. santosh wrote:
    >
    > Richard Heathfield wrote:

    [...]
    > > >> "This is the big hurdle", as Brian Kernighan rightly said. Everything
    > > >> else in C is relatively simple by comparison.

    [...]
    > > I stand by my original statement. Compared to the challenge of getting
    > > "hello world" up and running, *especially* if nobody has been kind enough
    > > to install a compiler for you, the rest of C is relatively simple.

    >
    > In practically every C course I can think of, a ready to use compiler
    > and environment were provided. If someone is going to learn C at home,
    > then he ought to familiarize himself with the basic usage of
    > computers, (manipulating files, installing programs etc.), before
    > attempting to learn C.
    >
    > In summary what you say would be true only in two cases, (I can think
    > of):
    >
    > 1. Attempting to learn C before learning the basics of using
    > computers.


    Considering how many people try to use computers before learning the
    basics of using computers, I think the field is pretty wide open for
    this one.

    > 2. Attempting to write your first program before getting the basics of
    > C syntax down pat.


    As I recall, I created/compiled/ran "Hello world" before I knew much
    about C beyond the first few pages of K&R.

    Yes, I was quite familiar with programming in general, having already
    been self-taught in numerous languages. Yes, I knew how to use the
    computer, and was able to install the C compiler, and use a text
    editor.

    Even so, there was a certain little thrill the first time the compile
    worked and the "Hello world" message appeared on my screen when I ran
    the program.

    Nowadays, when people are spoon-fed pre-installed IDEs which can make
    a complete "project" for you at the click of a button or two, I can't
    see someone getting that same thrill.

    I still agree with Mr. Heathfield, however.

    --
    +-------------------------+--------------------+-----------------------+
    | Kenneth J. Brody | www.hvcomputer.com | #include |
    | kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
    +-------------------------+--------------------+-----------------------+
    Don't e-mail me at: <mailto:>
     
    Kenneth Brody, Oct 24, 2007
    #14
  15. abi

    santosh Guest

    Kenneth Brody wrote:

    > santosh wrote:
    >>
    >> Richard Heathfield wrote:

    > [...]
    >> > >> "This is the big hurdle", as Brian Kernighan rightly said.
    >> > >> Everything else in C is relatively simple by comparison.

    > [...]
    >> > I stand by my original statement. Compared to the challenge of
    >> > getting "hello world" up and running, *especially* if nobody has
    >> > been kind enough to install a compiler for you, the rest of C is
    >> > relatively simple.


    >> In summary what you say would be true only in two cases, (I can think
    >> of):
    >>
    >> 1. Attempting to learn C before learning the basics of using
    >> computers.

    >
    > Considering how many people try to use computers before learning the
    > basics of using computers, I think the field is pretty wide open for
    > this one.
    >
    >> 2. Attempting to write your first program before getting the basics
    >> of C syntax down pat.

    >
    > As I recall, I created/compiled/ran "Hello world" before I knew much
    > about C beyond the first few pages of K&R.
    >
    > Yes, I was quite familiar with programming in general, having already
    > been self-taught in numerous languages. Yes, I knew how to use the
    > computer, and was able to install the C compiler, and use a text
    > editor.


    In my estimation the difficulty of entering, saving, compiling and
    running a "hello world" program has nothing to do with C and all to do
    with the details of operating the system.

    In which case, if for someone, this was their greatest challenge in
    learning C, I can only conclude that they attempted to learn C before
    becoming adequately familiar with their system.

    I personally started programming about a year after I started on
    computers, so this wasn't a problem to me. Also modern computing
    environments are significantly more intuitive and easier to operate
    than in the days of K&R.

    Still this type of difficulty typically arises when someone starts on
    programming without being familiar with more basic operations like
    editing files, using the commandline and so on.

    <snip>
     
    santosh, Oct 24, 2007
    #15
  16. abi

    Larry__Weiss Guest

    Richard Heathfield wrote:
    > santosh said:
    >
    >> Richard Heathfield wrote:
    >>
    >>> abi said:
    >>>
    >>>> hi,
    >>>> i have a c program in notepad. How to convert it or how to
    >>>> compile
    >>>> it?
    >>>
    >>> "This is the big hurdle", as Brian Kernighan rightly said. Everything
    >>> else in C is relatively simple by comparison.

    >>
    >> <snip>
    >>
    >> I personally found this to be the smallest hurdle in learning C.

    >
    > It has rightly been said that the distance between 0 and 1 is greater than
    > the distance between 1 and 1000. (Your mileage may vary. Mathematicians
    > need not apply. May contain nuts.)
    >
    > When I first learned C, I did so by taking a 13-week course. We were given
    > quite a few days of classroom stuff before we were let loose on a
    > computer. Our first task was "hello, world". We didn't have to install the
    > compiler - that had already been done for us, thank heaven.
    >
    > One of the people in the class (a very promising student, it seemed to the
    > rest of us) got quite a few (I think it was 13) compilation errors. He got
    > up and walked out of the lab, and we never saw him again.
    >
    > We all know that he's probably made just one mistake, or possibly two -
    > maybe a missing semicolon, maybe a 0 instead of a ), or whatever. Had he
    > fought his way over that hurdle, I'm sure he would have made a perfectly
    > good C programmer. But it was too big a *perceived* hurdle for him.
    >
    > I stand by my original statement. Compared to the challenge of getting
    > "hello world" up and running, *especially* if nobody has been kind enough
    > to install a compiler for you, the rest of C is relatively simple.
    >


    I never have found string handling to be simple in any sense in C.
    Perhaps it's just a personal flaw or blind-spot, but having to
    explicitly do the memory management makes it inherently not simple for me.

    - Larry
     
    Larry__Weiss, Oct 25, 2007
    #16
  17. Larry__Weiss wrote:

    > I never have found string handling to be simple in any sense in C.
    > Perhaps it's just a personal flaw or blind-spot, but having to
    > explicitly do the memory management makes it inherently not simple for me.


    <OT>
    You haven't programmed on Symbian, have you? Their string handling makes
    C strings look not only simple, but also beautiful.
    </OT>
     
    Peter Pichler, Oct 25, 2007
    #17
  18. abi

    Larry__Weiss Guest

    Peter Pichler wrote:
    > Larry__Weiss wrote:
    >
    >> I never have found string handling to be simple in any sense in C.
    >> Perhaps it's just a personal flaw or blind-spot, but having to
    >> explicitly do the memory management makes it inherently not simple for
    >> me.

    >
    > <OT>
    > You haven't programmed on Symbian, have you? Their string handling makes
    > C strings look not only simple, but also beautiful.
    > </OT>


    <OT>
    No, I have not.

    Symbian must be a truly esoteric language in that it has yet to be
    registered in either of these collections:

    http://www.roesler-ac.de/wolfram/hello.htm
    http://www.99-bottles-of-beer.net/

    </OT>

    - Larry
     
    Larry__Weiss, Oct 25, 2007
    #18
  19. abi

    Richard Bos Guest

    Larry__Weiss <> wrote:

    > Peter Pichler wrote:
    > > Larry__Weiss wrote:
    > >
    > >> I never have found string handling to be simple in any sense in C.
    > >> Perhaps it's just a personal flaw or blind-spot, but having to
    > >> explicitly do the memory management makes it inherently not simple for
    > >> me.

    > >
    > > <OT>
    > > You haven't programmed on Symbian, have you? Their string handling makes
    > > C strings look not only simple, but also beautiful.
    > > </OT>

    >
    > <OT>
    > No, I have not.
    >
    > Symbian must be a truly esoteric language


    Not _in_ Symbian, _on_ Symbian. An operating system for mobile devices.

    Richard
     
    Richard Bos, Oct 26, 2007
    #19
  20. In article <4all.nl>,
    Richard Bos <> wrote:
    >Larry__Weiss <> wrote:
    >
    >> Peter Pichler wrote:
    >> > Larry__Weiss wrote:
    >> >
    >> >> I never have found string handling to be simple in any sense in C.
    >> >> Perhaps it's just a personal flaw or blind-spot, but having to
    >> >> explicitly do the memory management makes it inherently not simple for
    >> >> me.
    >> >
    >> > <OT>
    >> > You haven't programmed on Symbian, have you? Their string handling makes
    >> > C strings look not only simple, but also beautiful.
    >> > </OT>

    >>
    >> <OT>
    >> No, I have not.
    >>
    >> Symbian must be a truly esoteric language

    >
    >Not _in_ Symbian, _on_ Symbian. An operating system for mobile devices.
    >
    >Richard


    Yes, I looked it up in Wikipedia. It seems strange to talk about an
    _operating system_ having a strange (or whatever other descriptive you
    choose) string handling "paradigm" (or system, or whatever), when
    usually that sort of thing is an attribute of the _programming language_.
     
    Kenny McCormack, Oct 26, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page