Sorry I didnt see it, even when it was starring me in my eyes. Okay here is the reposrt with the tags.
Code:
main.c
#include "grep.h"
#include "cat.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void main(int ac, char *av[])
{
if(strcmp("av[1]", "grep")==0)
{
fp=fopen("av[3]", "r");
if(fp!=NULL)
grep(fp,av[2]);
else
printf("Bad file entered\n");
}
else if(strcmp("av[1]", "cat")==0)
{
fp=fopen("av[3]", "r");
if(fp!=NULL)
cat(fp,av[2]);
else
printf("Bad file entered\n");
}
else
{
printf("Bad file entered\n");
exit(1);
}
}
***ERRORS***
GREP.H: FILE cannot start a parameter declaration
CAT.H: FILE cannot start a parameter declaration
main.cpp: Extra parameter in call to grep(int *)
main.cpp: Extra parameter in call to cat(int *)
main.cpp: Undefined Symbol 'fp'
Code:
cat.c
#include "cat.h"
#include <stdio.h>
void (FILE *fp)
{
while((c=fgets(fp))!=EOF)
putchar(c);
}
***ERRORS***
CAT.H: FILE cannot start a parameter declaration
CAT.C expected
Code:
grep.c
#include "grep.h"
#include <stdio.h>
void (FILE *fp)
{
//char s[1000];
//FILE *fp;
for (i=2;i<ac;i++)
{
fp=fopen(av[i],"r");
if(fp==NULL)
printf("%s is not Found\n",av[i]);
else
{
while(fgets(s,1000,fp) != NULL)
if(strstr(s,av[1])!=NULL)
printf("%s: %s", av[i], s);
}
fclose(fp);
}
}
***ERRORS***
GREP.H: FILE cannot start a parameter declaration
GREP.C expected
Code:
cat.h
#ifndef CAT
#define CAT
void cat(FILE *fp);
#endif
Code:
grep.h
#ifndef GREP
#define GREP
void grep(FILE *fp);
#endif
Sorry once again for not using tags. I see how they make things a lot easier for ppl to read.