I am really starting to freak out...
What am I doing wrong. I'll be back, need to take a walk. This is the thrid time I have rebuilt my adding to tree functions
Code:
///////////////////////////////////////////////////////////////////////
// Program : Lab05
// Function : getData
// File : getData.c
// Description : Extract upto x lines of data from file
// : quit when a blank line is found
// Variable Ref : dataList - list of company info
// : fp - File pointer
// : linesR - Number of lines returned
// : buffer - temporary line storage
// : buffer2 - temporary line storage
// : str - tokenized line storage
// : str2 - tokenized line storage
//////////////////////////////////////////////////////////
#include "lab05.h"
FILE *getData ( char *dataList[5], FILE *fp, int *linesR){
int i;
char buffer [MAX];
char buffer2 [MAX];
char *str;
char *str2;
i = 0;
while ( (fgets ( buffer, MAX-1, fp ) != EOF) ){
// Exit Prgm if 'i' is five, as there can only be
// 5 or less lines in the company data (0, 1, 2, 3, & 4)
if ( i == 5 ){
printf("\nError FFFE : Data file setup incorrectly. Exiting");
fputs("Error FFFE : Data file setup incorrectly. Exiting", stderr);
exit(0);
}
strcpy ( buffer2, buffer );
// Used to see if line is blank
str = strtok ( buffer, REMOVE );
// Take out the new line character
str2 = strtok ( buffer2, "\n" );
//
if ( str == NULL ){
return fp;
*linesR = i;
}
// Add str2 to 'dataList'
strcpy ( dataList[i] , str2);
printf("\ngetData 1.0 : dataList[%d] : <%s>", i, dataList[i]);
// Add one to i
i++;
}
*linesR = i;
return fp;
}
Code:
(c1400a01@pstcc11) #:~/1400/Lab05> make
gcc -Wall -c main.c
gcc -Wall -c promptFile.c
gcc -Wall -c fileOpen.c
gcc -Wall -c buildTree.c
buildTree.c: In function `buildTree':
buildTree.c:52: warning: comparison between pointer and integer
buildTree.c:62: warning: passing arg 1 of `getData' from incompatible pointer type
buildTree.c:64: warning: value computed is not used
gcc -Wall -c skipEntry.c
gcc -Wall -c upperAll.c
gcc -Wall -c displayTree.c
gcc -Wall -c getData.c
getData.c:18: conflicting types for `getData'
lab05.h:40: previous declaration of `getData'
getData.c: In function `getData':
getData.c:28: warning: comparison between pointer and integer