The multiple file nature of your design is almost, but not quite,
irrelevant.
/* project.h */
struct list {
struct list *next;
char *stuff;
}
int bar(struct list *);
/* project.c */
#include "project.h"
int main()
list *foo;
/* create list */
bar(foo);
return 0;
}
/* barzoo.c */
#include "project.h"
int bar(struct list *salami)
{
/* do stuff & return value */
}
>
> The second question is this,
> I have an if statement to compare values from the array, to produce a
> results table.
>
> The data field is a char* and I need it to recognise which char is
> given,
>
> if(datastructure->data[i].field == 'S')
if (!strcmp(datastructure->data[i].field,"S")
{ /* do stuff */ }
--
Martin Ambuhl (mam...@earthlink.net)
Note: mam...@tiac.net will soon be inactive
Or -- post the minimum code required to show the error.
Paul Lutus
Whiteknight wrote in message <368978D0...@virgin.net>...
>The problem is this,
>I am writing a program that reads data from file into an array,but then
>must store this data into a linked list.this has to be done using
>multiple source files.
>
>I have written the part that reads the data and produces the array, andd
>I have the part that sets up the linked lists, How do I make the second
>part be able to read the data from the first part.
>
>The second question is this,
>I have an if statement to compare values from the array, to produce a
>results table.
>
>The data field is a char* and I need it to recognise which char is
>given,
>
>if(datastructure->data[i].field == 'S')
>
>I have traced through the program with a debugger, although the data
>items match, The program doesn`t accept this and skips the code within
>the section.
>If anyone has any idea I'd like to know what I'm doing wrong, any help
>would be gratefully recieved.
>
<Jack>
Almost certainly the biggest mistake you are making is that you are
either ignoring warnings from the compiler, or you have the warning
level set way too low. The other possibility is that you described
your structure incorrectly, or I read your description incorrectly. I
can't say for sure because you did not include the actual definition
of your structure.
You have said that field is a pointer to char, and you are comparing
it to a character constant, which is an int. You should be getting a
compiler warning about comparing a pointer to an int without a cast.
Try something like:
if (datastructure->data[i].field[0] == 'S')
This compares the first character in the pointed-to string to the
character constant 'S'.
</Jack>
--
Do not email me with questions about programming.
Post them to the appropriate newsgroup.
Followups to my posts are welcome.