Newbie Question about Hello World 
Author Message
 Newbie Question about Hello World

I'm working through the second edition of Kernighan and Ritchie's book "The
C Programming Language". Using the lcc-win32 compiler on a Windows98:

#include <stdio.h>

main()
{
 printf("hello, world\n");
 }

will only compile when changed to:

#include <stdio.h>
#include <windows.h>

int main(void)
{
 printf("hello, world\n");
 return 0;

Quote:
}

What compiler can I use that compiles Kernighan and Ritchie's example's
without adding extra words and lines? The system I use the most is Windows
2000.


Sun, 19 Jun 2005 03:08:26 GMT  
 Newbie Question about Hello World


Quote:
> I'm working through the second edition of Kernighan and Ritchie's book
> "The C Programming Language". Using the lcc-win32 compiler on a
> Windows98:

> #include <stdio.h>

> main()
> {
>  printf("hello, world\n");
>  }

Main must return 'int' and one should explicitly state this in the
definition of the function, e.g. int main(void) where I add void since I'm
{*filter*}retentive. Try:

--- START ---
#include <stdio.h>

int main(void)
{
    printf("Hello world\n");

    return 0;

Quote:
}

--- END ---

If you compile the lines between START and END does your compiler finish
without error?

Quote:
> #include <windows.h>

This should never be required for ISO C programs.


Sun, 19 Jun 2005 03:14:52 GMT  
 Newbie Question about Hello World

Quote:
> I'm working through the second edition of Kernighan and Ritchie's book
"The
> C Programming Language". Using the lcc-win32 compiler on a Windows98:

> #include <stdio.h>

> main()
> {
>  printf("hello, world\n");
>  }

> will only compile when changed to:

> #include <stdio.h>
> #include <windows.h>

> int main(void)
> {
>  printf("hello, world\n");
>  return 0;
> }

> What compiler can I use that compiles Kernighan and Ritchie's example's
> without adding extra words and lines? The system I use the most is Windows
> 2000.

Why do you need <windows.h>? It should work fine without it.

Gregory Pietsch



Sun, 19 Jun 2005 03:16:17 GMT  
 Newbie Question about Hello World

Quote:

> I'm working through the second edition of Kernighan and Ritchie's book "The
> C Programming Language". Using the lcc-win32 compiler on a Windows98:

> #include <stdio.h>

> main()
> {
>  printf("hello, world\n");
>  }

> will only compile when changed to:

> #include <stdio.h>
> #include <windows.h>

> int main(void)
> {
>  printf("hello, world\n");
>  return 0;
> }

I'd be surprised if lcc-win32 doesn't have a mode that would
allow the former to compile.  Please refer to your compiler
documentation for more information, or ask in a newsgroup
specific to lcc-win32.
--
"You call this a *C* question? What the hell are you smoking?" --Kaz


Sun, 19 Jun 2005 03:13:08 GMT  
 Newbie Question about Hello World

Quote:

> I'm working through the second edition of Kernighan and Ritchie's book "The
> C Programming Language". Using the lcc-win32 compiler on a Windows98:

I'd advise learning the modern version of the language.
It would serve you much better in the future.

Quote:

> #include <stdio.h>

> main()
> {
>  printf("hello, world\n");
>  }

> will only compile when changed to:

> #include <stdio.h>
> #include <windows.h>

If it needs windows.h for this program, then the compiler
is extremely broken.

Quote:

> int main(void)
> {
>  printf("hello, world\n");
>  return 0;
> }

> What compiler can I use that compiles Kernighan and Ritchie's example's
> without adding extra words and lines? The system I use the most is Windows
> 2000.

Try asking on a Windows 2000 programming newsgroup for
correct answers.

You will need one that accepts "traditional k&r C".
cygwin, mingw, djcc come to mind (all these are based on GCC).
Borland has a few versions available too.
Watcom has just released a free version of their compiler.
Microsoft will sell you a compier that supports their standards
(whatever their compiler happens to do is the standard).



Sun, 19 Jun 2005 04:48:38 GMT  
 Newbie Question about Hello World
Yes, the following does compile in lcc-win32 on my Win98 machine:

#include <stdio.h>

int main(void)
{
 printf("hello, world\n");
 return 0;

Quote:
}

Thanks for all the responses. Onward and upward! I assume the modern version
of C is ISO C?


Sun, 19 Jun 2005 06:02:47 GMT  
 Newbie Question about Hello World
On Tue, 31 Dec 2002 14:08:26 -0500, in comp.lang.c , "Tim Sprout"

Quote:

>I'm working through the second edition of Kernighan and Ritchie's book "The
>C Programming Language". Using the lcc-win32 compiler on a Windows98:

>#include <stdio.h>

>main()
>{
> printf("hello, world\n");
> }

>will only compile when changed to:

>#include <stdio.h>
>#include <windows.h>

>int main(void)
>{
> printf("hello, world\n");
> return 0;
>}

I don't think so. You can for sure remove the Windows.h line.

Unless you've accidentally created a Win32 GUI project of course. Make
sure you're building with lcc options to create a Win32 Console app,
not a GUI one.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>



Sun, 19 Jun 2005 06:59:22 GMT  
 Newbie Question about Hello World
All windows compatible compilers will have an option to compile as a
console or windows executable. In reality, this means little because
checking the "windows" option will usually still allow you to compile a
console (and indeed the console is actually just a Windows program in
disguise), but may complain when no reference to windows.h or WinMain
are present. Just read you compiler's documentation or even browse the
IDE's menu.

--
posted via MFF :  http://www.MainFrameForum.com - USENET Gateway



Sun, 19 Jun 2005 06:26:53 GMT  
 Newbie Question about Hello World

Quote:
> I'm working through the second edition of Kernighan and Ritchie's book "The
> C Programming Language". Using the lcc-win32 compiler on a Windows98:

> #include <stdio.h>

> main()
> {
>  printf("hello, world\n");
>  }

Should be

#include <stdio.h>

int main()
{
   printf("hello, world\n");
   return 0;

Quote:
}
> will only compile when changed to:

> #include <stdio.h>
> #include <windows.h>

> int main(void)
> {
>  printf("hello, world\n");
>  return 0;
> }

The first version should work.

Quote:
> What compiler can I use that compiles Kernighan and Ritchie's example's
> without adding extra words and lines? The system I use the most is Windows
> 2000.

Be sure that the project you are making is a Win32 Console Application.

--
-ed- emdel at noos.fr ~]=[o
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
C-library: http://www.dinkumware.com/manuals/reader.aspx
"Mal nommer les choses c'est ajouter du malheur au monde."
-- Albert Camus.



Sun, 19 Jun 2005 11:44:39 GMT  
 Newbie Question about Hello World
On 31 Dec 2002 17:26:53 -0500, in comp.lang.c , Sebastian M.

Quote:

>All windows compatible compilers will have an option to compile as a
>console or windows executable.

Of course.

Quote:
>In reality, this means little because
>checking the "windows" option will usually still allow you to compile a
>console (and indeed the console is actually just a Windows program in
>disguise),

Its OT and you snipped all the context, but on the offchance you're
responding to my post, this is not correct since the IDE will link
different startup code which will expect a WinMain to exist.

Quote:
>but may complain when no reference to windows.h or WinMain
>are present.

Complain in the sense of fail to compile or link.

Quote:
>Just read you compiler's documentation or even browse the
>IDE's menu.

indeed

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>



Sun, 19 Jun 2005 18:38:24 GMT  
 Newbie Question about Hello World

Tim Sprout wrote

| I'm working through the second edition of Kernighan and Ritchie's book
| "The C Programming Language". Using the lcc-win32 compiler on a
| Windows98:

IMO there's no better compiler for leaning Standard C than GCC - the de
facto C compiler. Not only has it excellent diagnostics, but you will
probably learn and There are plenty of ports available for Windows. It's the
de facto C compiler, it has excellent diagnostics and you can learn a
surprising amount about its use in clc.

| What compiler can I use that compiles Kernighan and Ritchie's example's
| without adding extra words and lines? The system I use the most is Windows
| 2000.
|
|



Mon, 20 Jun 2005 03:34:04 GMT  
 Newbie Question about Hello World

Tim Sprout wrote

<snip>

| What compiler can I use that compiles Kernighan and Ritchie's
| example's without adding extra words and lines? The system I use
| the most is Windows 2000.

lcc will compile K&R's examples, given the right switches. But IMO you
should save yourself the trouble and switch to a Windows port of GCC, the de
facto C compiler. Here's what it has to say about your hello code:

hello.c:4: warning: return type defaults to `int'
hello.c: In function `main':
hello.c:6: warning: control reaches end of non-void function

I'd particularly recommend MinGW http://www.mingw.org/

JS
<apologies if there's an unfinished post from me - accidently hit the send
keyboard shortcut dammit>



Mon, 20 Jun 2005 03:52:31 GMT  
 Newbie Question about Hello World
Actually ISO C refers to the standard C language (aka ANSI C) without any
operating system specific extensions.
The most modern C specifications that I am aware of is C99. However I am not
sure if there are compilers for it.

Andrew.


Quote:
> Yes, the following does compile in lcc-win32 on my Win98 machine:

> #include <stdio.h>

> int main(void)
> {
>  printf("hello, world\n");
>  return 0;
> }

> Thanks for all the responses. Onward and upward! I assume the modern
version
> of C is ISO C?



Mon, 20 Jun 2005 06:39:53 GMT  
 Newbie Question about Hello World
in comp.lang.c i read:

Quote:

>> I'm working through the second edition of Kernighan and Ritchie's book "The
>> C Programming Language". Using the lcc-win32 compiler on a Windows98:

>I'd advise learning the modern version of the language.

k&r2 does describe a fairly recent version of the language, though not c99.
a compiler that is pre-c99 must accept the code posted.  i've no idea about
lcc-win32, but lcc-linux compiles it without any problem (it does warn that
there is no return value).

--
bringing you boring signatures for 17 years



Mon, 20 Jun 2005 10:29:11 GMT  
 Newbie Question about Hello World
in comp.lang.c i read:

Quote:
>IMO there's no better compiler for leaning Standard C than GCC - the de
>facto C compiler.

provided you disable the gcc extensions and enable warnings.  i suggest:

-g3 -O -Wall -W -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs
-Wpointer-arith -Wundef -Wshadow -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Wconversion -Winline -ansi
-pedantic

ajusted to suit conditions.

--
bringing you boring signatures for 17 years



Mon, 20 Jun 2005 10:34:14 GMT  
 
 [ 19 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Newbie: SetDlgItemText(IDC_EDIT2,"hello world") error

2. a hello world encryption

3. Canocical hello world

4. The Program Only Harder Then Hello World...

5. Hello World not working

6. Hello World Problem

7. Hello World

8. Hello world without semicolon

9. Hello World

10. Hello World problems

11. Hello World Web service

12. Hello world!

 

 
Powered by phpBB® Forum Software