From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: - HELP! - a little mixed up in C/C++ pointers Date: Tue, 19 Aug 1997 19:38:18 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 61 Message-ID: <33F9F62A.2101@cs.com> References: <33F7F642 DOT 30B9 AT usa DOT net> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp106.cs.com 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 Gal wrote: > > Okay here I start: With a basic C/C++ question that really belongs in other fora. comp.lang.c or comp.lang.c.moderated would be better places to ask this sort of thing. However, I'll take a shot at answering it. :) > // defining types variables > struct IndexFileName { > char FileName[12]; > } > > int IndexFileName; This definition means nothing; you are declaring a variable of type int named IndexFileName, not a structure. Assuming you want to declare a global structure of type 'struct IndexFileName', then you do it like this: struct IndexFileName Index; > // our function > int compare (char *FileName) > { > return strcmp(Index.FileName, FileName); > } This comparison will then become valid, as will the rest of your code. > //main > void main () > { > printf("%d\n", compare("TEST.TST")); > return 0; > } You are declaring main() as void, but you have it returning a value. This is an error; you must always declare main() as returning an integer. > The question is, what do I have to put in front of "Index.FileName" > in order to have it become a pointer so I can do a compare? I'm a bit > mixed up in C :) Any array label in C is automatically a pointer. The problem is that you never defined the variable named 'Index'. Please try to find a good C reference book, or take a course. Based on the difficulty you're having, it would seem that you're jumping into shark-infested waters without a life raft. :) hth -- --------------------------------------------------------------------- | John M. Aldrich | "A generation which ignores history | | aka Fighteer I | has no past--and no future." | | mailto:fighteer AT cs DOT com | | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------