TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Joe Kelch
from: Bob Plyler
date: 1995-04-16 10:42:00
subject: Borland Strings

* In a message originally to All, Joe Kelch said:
 > Every time I try to declare a string variable like this:

 > char *StrName;

 > and then attempt to read in a string using something like:

 > gets(StrName);

 > I get an access violation as soon as my program attempts to
 > try and jump to a

Thats because, via your declaration, you have declared a pointer,
but haven't pointed it to anything.  It is probably pointing to NULL.
Dos will accept this gladly, and overwrite anything at 0:0.  OS/2 will
complain LOUDLY if you try and write to this location.

I would suggest adding:

StrName = malloc(50);

This will initialize the pointer in StrName.

Bob Plyler

--- GEcho 1.11+
* Origin: The Transporter Room: 8 lines 22gig! 30 CD's 704/567-9513 (1:379/1)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 379/1 3615/50 396/1 270/101 105/103 42 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.