struct dir_t {
char *name; // Name of directory
int owner; // ID of owner
int num_files; // number of files in directory
file_t files[1024]; // file descriptors
};
enum FILETYPE { IMAGE, TEXT, MUSIC, MOVIE, MAX_FILE_TYPE };
struct file_t {
char *name; // Name of file
FILETYPE type; // Type of file
int owner; // ID of owner
bool is_public; // true if file is public
int location; // location on disk
};
bool has_string(const dir_t &d, int uid, constchar * s);
/* REQUIRES: s is a valid C-string
* EFFECTS: returns true if any public text file
* owned by user uid contains s.
*/
//YOU HAVE ACCESS TO
bool find_in_file(int loc, constchar * s);
/* REQUIRES: s is a valid C-string,
* loc is the location of a file on disk
* EFFECTS: returns true if the string is found within the file
*/
So my final if statment is (I start with a for(i = 0; i < d.num_files; i++) loop) if(find_in_file(d.files[i].location,*s)){//blah blah}
My question is, do I use *s or just s? in the call to find_in_file. Char *s means s is a pointer to a character, that has been intalized to whatever you throw in the function all, so I feel like *s should work, but I am not sure. Can anyone let me know?
If your s is a char*, *s would be a char. You can see that find_in_file wants a (const) char* and not a char, so pass s. If s was a char**, *s would be a char* so you would have to pass *s.