www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/30/19:45:21

From: av568 AT rgfn DOT epcc DOT edu (Beautiful Savior Lutheran Church)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: VERY basic question
Date: 30 Apr 1997 21:49:43 GMT
Organization: The Rio Grande Free-Net, El Paso Community College, El Paso, TX
Lines: 51
Message-ID: <5k8epn$55q@news.epcc.edu>
References: <5k688j$2vp$1 AT newserve DOT gulftel DOT com>
NNTP-Posting-Host: rgfn.epcc.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

RobertL.Mackey wrote:
> I am using DJGPP V2.01and RHIDE. I have been using them for 3 days. 
> I have tried to teach myself c and c++. I wrote a standard "Hello, World"
> program, and it chrashed. I was running under a DOS box in W3.1 so I 
> wouldn't have to fool with DPMI. The program is as follows.
> #include "include/stdio.h"
> void main() {
>       printf("Hello World", %s); 
> }
> First it complained about a file, include/sys/djtypes.h, which it said
> was missing. (It wasn't.) I played around with <>s and "" and finally 
> got that fixed.  Then it said somthing about a parse error before the %.
> Finally, it compiled. I ran the program and got shot back to windows,

Your #include directive is totally wrong. Just specify <stdio.h> and 
it'll work. Your printf() statement is incorrect as well; it seems that 
you want:

	printf("%s", "Hello World");
or maybe
	printf("Hello World");

but what you put is wrong.

> where it said HELLO.EXE had violated system integrity. HOW DOES 
> "HELLO, WORLD" VIOLATE SYSTEM INTEGRITY. Any thoughts?

In the DOS or Unix world, this is a SIGSEGV, or Segmentation Violation. 
Your program tries to access the variable "%s" (or maybe "s" depending on 
what your final program was) which printf() assumes to be a pointer to 
char (I think) and tries to dereference. Since it is a near certainty 
that whatever the ficticious "s" contains will not be a valid pointer, 
you get a Segmentation Violation.

> Also, I downloaded the C++ compiler and library files. The library files
> say I have to run a makefile or something like that. How do I do that?

> Also, I learned the syntax and rules and all that.. Now what do I do
> with this? I can't think of any programs to write. I don't know 
> any graphics or anything like that Any tips for a beginner?

No offense, but it seems you did not learn them well. Did you read a book 
on C by Herbert Schildt? :) I recommend a good book like "The C 
Programming Language, Second Edition" by Brian Kernighan and Dennis 
Ritchie. If your bookstore doesn't have it, stop going there. :)

> PLEASE REPLY TO maf01028 AT acan DOT net. DON'T HIT REPLY! Thanks a lot for the help.

--
Beautiful Savior Evangelical Lutheran Church - av568 AT rgfn DOT epcc DOT edu
We have what you need-- A Savior!

- Raw text -


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