I wasted my whole day trying to find this silly error but didn't get through
I am trying to compile
Code:
/*
file: filesearch.c
*/
#include <string.h>
#include <windows.h>
#include "filesearch.h"
#include "stack.h"
void getCurrentPath(char *path)
{
GetCurrentDirectory(MAX_PATH,path);
}
void searchpath(char *path,char *pattern,struct strData **filestack)
{
HANDLE hsearch;
WIN32_FIND_DATA FileData;
char tempdata[MAX_PATH];
struct stkData *dirstack,tempstack;
initstack(&dirstack);
initstack(filestack);
if(SetCurrentDirectory(path)){
if((hsearch=FindFirstFile(pattern,&FileData)) != INVALID_HANDLE_VALUE){
do{
if(!(FileData.cFileName == "." || FileData.cFileName == "..")){
if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){
strncpy(tempstack.data,FileData.cFileName,strlen(FileData.cFileName));
push(&dirstack,tempstack);
}else{
strncpy(tempstack.data,FileData.cFileName,strlen(FileData.cFileName));
push(filestack,tempstack);
}
}
}while(FindNextFile(hsearch, &FileData));
FindClose(hsearch);
}
while(!isEmpty(&dirstack)){
tempstack = pop(&dirstack);
searchpath(tempstack.data,pattern,filestack);
}
}
}
these are the header files
Code:
#ifndef _FILESEARCH_H
#define _FILESEARCH_H
void getCurrentPath(char *);
void searchpath(char *,char *,struct strData **);
#endif
Code:
#ifndef _STACK_H
#define _STACK_H
#define PATHLENGTH 260
struct stkData{
char data[PATHLENGTH];
int status;
struct stkData *next;
};
void initstack(struct stkDat..........);
int isEmpty(struct stkDat..........);
void push(struct stkDat..........,struct stkData);
struct stkData pop(struct stkDat..........);
#endif
I am getting this error
Code:
D:\Project\C\stack>lcc filesearch.c
Error filesearch.c: 14 redeclaration of 'searchpath' previously declared at d:\project\c\stack\filesearch.h 4
1 errors, 0 warnings