C

A

arkmancn

abi said:
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.
 
U

user923005

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
$
 
R

Richard Heathfield

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.
 
S

santosh

abi said:
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.
 
S

santosh

Richard said:
abi said:


"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.
 
R

Richard

santosh said:
<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.
 
R

Richard Heathfield

santosh said:
<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.
 
S

santosh

Richard said:
santosh said:

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.
 
K

Kenneth Brody

santosh said:
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:[email protected]>
 
S

santosh

Kenneth said:
santosh said:
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>
 
L

Larry__Weiss

Richard said:
santosh said:


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
 
P

Peter Pichler

Larry__Weiss said:
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>
 
R

Richard Bos

Larry__Weiss said:
<OT>
No, I have not.

Symbian must be a truly esoteric language

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

Richard
 
K

Kenny McCormack

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_.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

C exercise 1
Become a C++ programmer 4
Compilation of old source code. 0
Meme generator in c 1
C Programming functions 2
External CSS 4
C# DataTable 1
C++ to C conversion 0

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top