www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/08/01:18:56

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Another Newbie Question: Help with Jlib
Date: Mon, 07 Jul 1997 12:56:49 -0700
Organization: Alcyone Systems
Lines: 37
Message-ID: <33C14A01.2FECBCDA@alcyone.com>
References: <19970707181801 DOT OAA16934 AT ladder02 DOT news DOT aol DOT com>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

SWars Matt wrote:

> I am just learning C++ programming, and I was trying to use Jlib with to
> initialize a buffer, plot some points, and display the buffer.  I kept
> getting errors like 'cannot convert from type buffer_rec to type
> buffer_rec *.  Can anyone show me the correct syntax to use with these
> commands?

The error is that you're trying to pass a value of type buffer_rec to a
function which in fact needs a pointer to a value of that type.  This is
the same thing as goofing up pointers with, say, ints:

    void f(int *ip);

    int i;

    f(i); /* this is illegal */
    f(&i); /* this is correct */

Note that depending on what the function _does_, passing the address of
your particular buffer_rec may not be the right thing to do -- but you'll
have to get to that when it comes up.  But clearly your first problem is
that you're passing the wrong type.

If this isn't making sense to you, you should get a good ANSI C book and
read the section on pointers over and over again until you know it like
the back of your hand, because knowledge and understanding of pointers in
C is essential.  Better yet, get more than one book and read each, to get
slightly different viewpoints on the material.

-- 
       Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com
                     Alcyone Systems /   web / http://www.alcyone.com/max/
San Jose, California, United States /  icbm / 37 20 07 N  121 53 38 W
                                   \
           "All the gods are dead / except the god of war."
                                 / Eldridge Cleaver

- Raw text -


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