From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Problem w/cin & structs Date: Mon, 08 Jun 1998 21:56:07 -0400 Organization: Two pounds of chaos and a pinch of salt. Lines: 47 Message-ID: <357C9637.FC766D4E@cs.com> References: <199806090112 DOT SAA05038 AT neptune DOT calstatela DOT edu> NNTP-Posting-Host: ppp209.cs.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk lsantil AT calstatela DOT edu wrote: > > Hi. > > I'm having a problem w/DJGPP's cin.getline w/a struct > [snip] Okay, you have two problems here. The first is that you're confusing a reference with a pointer in the declaration of chng(). void chng( thing &x ); This declaration tells the compiler that chng will accept a reference to an object of type thing. However, in your main(), you pass it a pointer to an object of type thing. chng(thing&) is not the same function to the compiler as chng(thing*), so it looks for the latter function. Not finding one, nor any way to convert a thing* to a thing&, it gives an warning. The second problem you report about cin.getline() is interesting, because gcc doesn't complain about it at all when I compile your code. I originally thought that it might dislike the implicit cast from unsigned char * to char *, but apparently not. If you actually get an error or warning from that line, please report it exactly (see chapter 6.10 of the DJGPP FAQ to learn how to redirect error messages to a file). A complaint: void is not a valid return type for main(). Int is the only legal ANSI return type, and if you compile with warnings on ('-Wall' flag), the compiler will tell you about it. If your book or instructor or sample program says otherwise, it's incorrect. If you manage to reproduce that error about cin.getline() that you say happened, please post it here so we can look at it. FYI, I used gcc 2.8.0 to compile your program; if you are using a different version (2.7.2.1 or 2.8.1), please tell us. hth! -- --------------------------------------------------------------------- | John M. Aldrich | "History does not record anywhere at | | aka Fighteer I | any time a religion that has any | | mailto:fighteer AT cs DOT com | rational basis." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------