Store data (langage C)
hi
this is a function to retrive text file Code:
int searchFile(char *directory, char *ext) somebody could post code to help me to do it? thanks |
You can name dirinfo a global variable or add third parameter to the function:
Code:
int searchFile(char *directory, char *ext,struct dirent **dirinfo) |
I would do it like this:
Code:
int searchFile(char *directory, char *ext,char *buf) |
Since dirent->d_name is only a string (char[256] to be specific), and if that's all you want from the struct, then I'd suggest either doing Mara's second option, but with a string:
Code:
int searchFile(char *directory, char *ext, char *dirinfo) Code:
#include <stdio.h> |
Quote:
What if d_name is longer than buf has storage space? strncpy is always a better choice. |
All times are GMT -5. The time now is 11:28 PM. |