Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<windows.h>
- #include<stdio.h>
- #include<string.h>
- int main(){
- WIN32_FIND_DATA FindFileData;
- HANDLE hf=FindFirstFile("D:\\proc\\*", &FindFileData);
- CHAR fileNames[200][MAX_PATH];
- INT i=0;
- if (hf==INVALID_HANDLE_VALUE)
- {
- puts("Path not found");
- return 1;
- }
- do{
- strcpy(fileNames[i], FindFileData.cFileName);
- //puts(fileNames[i]);
- ++i;
- }
- while (FindNextFile(hf,&FindFileData));
- FindClose(hf);
- char name[] = "D:\\proc\\";
- int k=2;
- CHAR fileNames1[200][MAX_PATH];
- INT i1=0;
- for(k=2; k<9; k++)
- {
- char* buff = calloc(strlen(name) + strlen(fileNames[k]) + 1, 1);
- strcat(buff, name);
- strcat(buff, fileNames[k]);
- strcat(buff, "\\");
- char* temp = calloc(buff + 1, 1);
- strncpy(temp, buff, strlen(buff));
- strcat(buff, "*");
- hf=FindFirstFile(buff, &FindFileData);
- if (hf==INVALID_HANDLE_VALUE)
- {
- puts("Path not found");
- return 1;
- }
- do{
- strcpy(fileNames1[i1], FindFileData.cFileName);
- //puts(fileNames1[i1]);
- ++i1;
- }
- while (FindNextFile(hf,&FindFileData));
- FindClose(hf);
- char s[100];
- char* buff1 = calloc(strlen(temp) + strlen("temp.txt") + 1, 1);
- strcat(buff1, temp);
- strcat(buff1, "temp.txt");
- FILE* f1 = fopen(buff1, "r");
- for(i=0;i<4;i++)
- {
- fgets(s,128,f1);
- if(i!=2)
- printf("%s", s);
- }
- printf("\n");
- putchar('\n');
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement