Mail Archives: djgpp/1997/08/20/00:38:27
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 |
---------------------------------------------------------------------
- Raw text -