Wednesday, 25 August 2010

Small Programs in c sample source codes(Quick hack convert M$ favorites to html list)

Quick hack convert M$ favorites to html list

#include <>
#include <>
#include <>
#include <>
#include <>
#include <>

#define PACKAGE "forvavo"

/* recursion */
void recdir(char *dir);

int main(int argc, char *argv[]) {
if(argc != 2)
fprintf(stderr, "%s [directory]\n", PACKAGE), exit(EXIT_FAILURE);
else {
printf("\n");
printf(" \n");
printf(" \n");
printf(" \n");
printf("\n");

recdir(argv[1]);

printf("\n");
printf("\n");
}

return 0;
}

void recdir(char *dir) {
DIR *dp;
FILE *fp;
char *ptr;
char line[1024];
struct dirent *entry;
struct stat statbuf;

if((dp = opendir(dir)) == NULL) {
fprintf(stderr, "Cannot open directory: %s\n", dir);
return;
}

chdir(dir);
while((entry = readdir(dp)) != NULL) {
stat(entry->d_name, &statbuf);
if(S_ISDIR(statbuf.st_mode)) {
if(strcmp(".", entry->d_name) == 0 || strcmp("..", entry->d_name) == 0)
continue;

printf("\n

%s

\n", entry->d_name);
printf("


Read more: http://cmagical.blogspot.com/2010_02_14_archive.html#ixzz0xgXu6hTq
Under Creative Commons License: Attribution Non-Commercial No Derivatives

No comments:

Post a Comment