www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/27/14:21:10

From: 006809c AT iceberg DOT acadiau DOT ca (Andrew Cheyne)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: [Q] using int 0x21 to print text with inline asm
Date: 26 Aug 97 20:36:23 GMT
Organization: Hub.Org Public Access Unix Server
Lines: 40
Message-ID: <34033e47.0@131.162.2.91>
References: <1 DOT 5 DOT 4 DOT 32 DOT 19970826130011 DOT 006a85d4 AT dce03 DOT ipt DOT br>
NNTP-Posting-Host: iceberg.acadiau.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Cesar Scarpini Rabak (csrabak AT dce03 DOT ipt DOT br) wrote:
: At 23:35 25/08/97 GMT, firewind wrote:

: [snipped]

: >> myHappy = "Hello, world!";
: >  ^^^^^^^^^^^^^^^^^^^^^^^^^^ (3)
: [snipped]

: >3: you're assiging a string to a variable, but this string really has no
: >   storage allocated for it.
: >

: This affirmation is incorrect! What this line of code does is to
: _initialize_ the pointer myHappy with the address of the first element of
: the constant array of char _"Hello, world!"_. Nothing particular wrong there.

  Actually, he was correct. You cant initialize a pointer to point to
something if you dont allocate memory for it. You CAN say

char* myHappy = "Hello, world!";

but that is different than:

char* myHappy;

myHappy = "Hello, World!";

You will also want to #include <string.h> so you can do a
strcpy(myHappy, "Hello, World!");

after you've allocated the space in myHappy.

Andrew

--
           ..  .  .   .   .   .   .  .   .   .   .   .   . . . 
   .      (    Andrew Cheyne   /   006809c AT dragon DOT acadiau DOT ca  ) 
     o  O  (     http://dragon.acadiau.ca/~006809c/           ) 
            (  ..   . .   .  .  .  .  .  ..    .  .   .  .   ) 

- Raw text -


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