delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/20/10:17:02

From: hat AT se-46 DOT wpa DOT wtb DOT tue DOT nl ()
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Please Help
Date: 20 Apr 1998 12:41:32 GMT
Organization: Eindhoven University of Technology, The Netherlands
Lines: 64
Message-ID: <6hffps$aim@tuegate.tue.nl>
References: <892202654 DOT 754158 AT proxy DOT netactive DOT co DOT za>
Reply-To: a DOT hofkamp AT wtb DOT tue DOT nl
NNTP-Posting-Host: se-46.wpa.wtb.tue.nl
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> I am learning C programming from a book.
> I donwloaded DJGPP along with RHIDE to compile the programs on.
> The first program in the book is very simple.
> 
> Here is the source :
> 
> 1: /*02L01.c : This is my first C program. */
> 2: #include <stdio.h>
> 3:
> 4: main ()
> 5: {
> 6:     printf ("Howdy, neighbor! This is my first C program. \n");
> 7:     return 0;
> 8: }

I take it that the numbers in the front are _NOT_ part of the C program ?
otherwise, you'll be in for a lot of trouble.

> When I compile it using RHIDE, I get error messages. I have tried removing
> the #include section.

You should do this in 2 steps. First check that the DJGPP compiler is
installed properly, then try to use tools like RHIDE.

If you followed the installation instructions,
you should be able to compile the program (in a DOS box) using

gcc 02L01.c

(at least, if that is the name of the program).
As result, you should get a file aout.exe
If not, post what the compiler is spitting to you, so we can see what
goes wrong.

There are a couple of nice options, which make living a lot easier, but
that is not the problem at this moment.

> If somebody can please compile this and try to figure out what I am doing
> wrong, it will be greatly appreciated.
> 
> The book says that all the programs conform to the ANSI standard, so I don't
> think that is the problem...

Actually, it is _NOT_ ANSI C, but the compiler should be able to swallow it.

(In ANSI, the code would look as follows:

/*02L01.c : This is my first C program. */
#include <stdio.h>

int main (void)
{
    printf ("Howdy, neighbor! This is my first C program. \n");
    return 0;
}

(note the use of 'int' and '(void)' in the definition of main)
For some reason, books never do this correctly... :-(


Albert
---
Sorry, no .sig
The sys admin wiped the previous sig, and I haven't invented a new one yet.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019