#include <stdio.h>
#include <stdlib.h>
#define SIZE 5
#define MAX 10
void fillArray(char arr[][MAX]);
void printArray(char arr[][MAX]);
int fileOpen(void);
int main(void)
{
char arr[SIZE][MAX];
int success;
fileOpen();
if (success == 1)
{
fillArray(arr);
printArray(arr);
}
else
printf("File access failed");
return 0;
}
int fileOpen(void) // ** this were i am having the most trouble
{
char fileInput;
char word[SIZE][MAX];
FILE *input;
int success;
if ((input = fopen("infile", "r")) !=NULL)
{
while ((fileInput = fgetc(input)) != EOF)
{
printf("\n file opened!");//remove
printf("\n Its working!\n ");//emove
strcpy(input, word);
putchar(fileInput);
fillArray(word);
}
printf("Failure in opening \"infile\" for writing.\n");
fclose(input);
}
else
{
printf("\n Could not access \"infile\" for reading.\n\n");
success = 0;
}
return success;
}
void fillArray(char word[][MAX])
{
char arr[SIZE][MAX]; // i also need guidance on how to fill the array with the
info from a the file "infile"
int i, j;
int names;
names = 0;
printf("FIllARRAY TIME!");
for (i = 0; i < SIZE; i++)
fscanf("%s", word[i]);
for(j = 0; j < MAX; j++)
if ( i < SIZE)
if ( j < MAX)
{
printf("%s", i, word[i][MAX]);
names = i;
printf("Named pairs = %d", names);
printf("\n\n");
}
else
printf("problem with data presented!");
}
void printArray(char arr[][MAX])
{
int i, j;
for (i = 0; i < SIZE; i++)
{
for (j = 0; j < MAX; j++)
printf("%s", arr[i][j]);
printf("\n");
}
}
any in sight would be helpful. im really under the gun and have been trying to get this to work for a couple of days.
thanks in advance
David