Ok started over with my code. First trying to make it easier to read.
Second was hard to read so I goot confused. Now I am trying to separate my project into proper function calls. I need my program to read the file, then parse it into separte words. Max number of words is a 100 and not repeat any word. I have started but am stuck.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FLUSH while (getchar() !='\n')
#define STR_LEN 81
//Function Declarations
void initialize(int* index, char strng[]);
int main(void)
{
// Local Declarations
char strng[1000];
char** pWords;
FILE* spIn;
int size = 100;
// Statements
printf("Data to Manipulate: \n\n");
if (!(spIn = fopen ("c:\\sample.txt", "r")))
{
printf("\aError could not open.\n");
system("Pause");
exit (100);
}//if
while (fgets (strng, sizeof (strng), spIn))
{
printf("%s", strng);
}
printf("\n\n");
FLUSH;
//Allocate array in heap.
pWords = (char **)calloc (size, sizeof *pWords);
printf("tests\n");
int index = 0;
initialize(&index, strng);
fgets(strng, sizeof (strng), spIn);
while (spIn)
{
sscanf(spIn, "%16[^'EOF']%4d", *(strng), &index);
index++;
}//while
system("PAUSE");
return 0;
}
/*================================initialize===================================
Build the table for the string of characters.
Pre- file in
Post words counted
*/
void initialize(int* index, char strng[])
{
//local Declarations
int j;
//pWords = 0;
for(j = 0; j < 100; j++)
printf("%4d = *strng[j]", j, *strng);
system("Pause");
return;
}//initialize
Can't get past my fuction call for initialize. What am I missing please help.
Thank you.