home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!seunet!pop!bjst
- From: bjst@sth.frontec.se (Bjorn Stenberg)
- Subject: Re: What is wrong with this very simple c program?
- Message-ID: <1992Nov20.133457.678@sth.frontec.se>
- Nntp-Posting-Host: pop.sth.frontec.se
- Organization: IDK/Frontec - System Design Group
- References: <BxIpyB.E7@unx.sas.com> <johnv.03kr@acix.DIALix.oz.au>
- Date: 20 Nov 92 13:34:57 GMT
- Lines: 30
-
- johnv@acix.DIALix.oz.au (John Verhoeven) writes:
- > Whats even more fun :-) is that in some compilers accessing arrays with
- > a negative subscript is also legal, eg foo[-1] = 5.
- >
- > Does SAS C V6 allow this ?
-
- It should! Check out this one:
-
- main()
- {
- char String_AC [30];
- char* StrPtr_PC = NULL;
-
- strcpy( String_AC, "Hello world.\n" );
- StrPtr_PC = &( String_AC[1] );
-
- if ( 'H' == StrPtr_PC[ -1 ] )
- printf( "Found it!\n" );
- else
- printf( "Failed.\n");
- }
-
- Somewhat dangerous if you're not cautious, but perfectly legal.
-
- -- Bjorn
-
-
- /// Bjorn Stenberg, Stockholm, Sweden bjst@sth.frontec.se
- /// main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}
- \\\ /// "- Your documentation no longer confuses me, old version!"
-