Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > C

Reply
 
 
abi
Guest
Posts: n/a
 
      10-23-2007
hi,
i have a c program in notepad. How to convert it or how to compile
it?

 
Reply With Quote
 
 
 
 
arkmancn@gmail.com
Guest
Posts: n/a
 
      10-23-2007

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.

 
Reply With Quote
 
 
 
 
user923005
Guest
Posts: n/a
 
      10-23-2007
On Oct 22, 6:13 pm, abi <(E-Mail Removed)> 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
$

 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      10-23-2007
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/...#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
 
Reply With Quote
 
Road Tang
Guest
Posts: n/a
 
      10-23-2007
abi wrote:

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


The first chapter of the most tutorial is how to compile and run.
So what's you need mostly is a formal tutorial of C.

It's also a good idea to google some for it.
http://www.google.com/search?hl=en&q...=Google+Search

HTH
Road
--
C FAQ: http://c-faq.com/
 
Reply With Quote
 
user923005
Guest
Posts: n/a
 
      10-23-2007
On Oct 22, 6:27 pm, Richard Heathfield <(E-Mail Removed)> 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/...#FreeCompilers


Don't forget Watcom C:

http://www.openwatcom.org/index.php/Download


 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      10-23-2007
user923005 said:

> On Oct 22, 6:27 pm, Richard Heathfield <(E-Mail Removed)> 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/...#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
 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      10-23-2007
user923005 <(E-Mail Removed)> writes:

> On Oct 22, 6:27 pm, Richard Heathfield <(E-Mail Removed)> 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/...#FreeCompilers

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


It's good to finally see the stalwarts being a little more open minded
and answering what would previously have been called "Off Topic".
 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      10-23-2007
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.

 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      10-23-2007
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments