Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
FILE_Access
//gcc 5.4.0 #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <string.h> unsigned char val; FILE *file_ptr=NULL, *fp_path=NULL; char fpath[100]="C:\\Users\\stodorov\\Downloads\\Notes\\"; char filenames[500][30]; char path_bool[]="0,0,0"; //-------------------- Reading the filenames --------------- void getfilenames() { DIR *dir; struct dirent *ent unsigned int i; if ((dir = opendir ("C:\\Users\\stodorov\\Downloads\\Notes\\")) != NULL) { i=0; memset(filenames,'\0',sizeof(filenames)); while((ent = readdir (dir)) != NULL) { puts (ent->d_name); strcpy(filenames[i++],ent->d_name); } (void) closedir (dp); //strcpy(filenames[i],not_founded); } else perror ("Couldn't open the directory"); } //------------------------ Path Set ------------------------ void path_set() { printf("The default path is : %s\n\n\r",fpath); /*printf("Y/N?"); //while(path_bool[0]==0) scanf("%s",&path_bool); if(path_bool[0]=='N') { printf("Enter path:"); scanf("%s",fpath); } printf("The set path is : %s\n\n\r",fpath); */ } //-------------------------- MAIN ------------------------- int main(void) { path_set(); getfilenames(); return 0; } //========================================================== DIR *dir; struct dirent *ent; if ((dir = opendir ("c:\\src\\")) != NULL) { /* print all the files and directories within directory */ while ((ent = readdir (dir)) != NULL) { printf ("%s\n", ent->d_name); } closedir (dir); } else { /* could not open directory */ perror (""); return EXIT_FAILURE; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
No warnings!!!
quadsort vs qsort
Spring 2017 Project 2 v.03
Divisibility :- #simple-math #ad-hoc-1 #basics
scanf and integer manipulation
20161118_ArrayRepetidos
Multiple if statement v0.8
blue saver go my marshal green
Print hostname
Lior Yehieli Lesson
Please log in to post a comment.