Article View: comp.sys.ibm.pc.programmer
Article #634Re: Bug in TC2.0
From: Torkil Hammer
Date: Tue, 05 Jun 1990 14:50
Date: Tue, 05 Jun 1990 14:50
25 lines
1221 bytes
1221 bytes
In article <RFROST.90Jun3234439@spam.ua.oz.au> rfrost@spam.ua.oz.au (Richard Frost) writes:
#
# I have found what I think is a bug in version 2.0 of the Turbo C compiler.
#
..
# char Test[] = {0xB0,0xB0,0xB0}; extern char *Test;
#
# main(int argc, char *argv[]) void testfn(void)
# { {
# ... ...
# testfn();
# Test[1] = 'A';
# *(Test+2) = 'B';
#
# } }
No, not a bug in the compiler. A bug in your code, in K&R as well as
ANSI standard. A pointer is not the same as an array. The code on
the right could work if you declared a global pointer named Test and
initialized it in the main program to point at the start of the global
array Test before calling testfn.
On a second thought, I think you will have to give the pointer a different
name from Test, but then it should work as desired.
Technical Details
Message-ID:
<3420@psivax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!psivax!torkilReferences:
<RFROST.90Jun3234439@spam.ua.oz.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!psivax!torkil From: torkil@psivax.UUCP (Torkil Hammer) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: Bug in TC2.0 Message-ID: <3420@psivax.UUCP> Date: 5 Jun 90 14:50:56 GMT References: <RFROST.90Jun3234439@spam.ua.oz.au> Distribution: comp.sys.ibm.pc.programmer Organization: Pacesetter Systems Inc., Sylmar, CA Lines: 25