Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 1:06
a random user23-May-15 1:06 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 2:15
mveRichard MacCutchan23-May-15 2:15 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 2:56
a random user23-May-15 2:56 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 3:04
mveRichard MacCutchan23-May-15 3:04 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 3:08
a random user23-May-15 3:08 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 3:45
a random user23-May-15 3:45 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 6:27
mveRichard MacCutchan23-May-15 6:27 
QuestionRe: C language Help using Dirent.h Pin
a random user23-May-15 9:47
a random user23-May-15 9:47 
I dont know if i fixed it or not because Just now i saw your comment
but this is how far i got in order to get to the second frole from the first file
but for some odd reason it stopps when i do malloc

#include <string.h>
#include <stdlib.h>
#include "dirent.h"

int main(int argc, char** argv)
{
DIR* OtherDir;
struct dirent *OtherEnt;

int location = 0, flag = 0, secSpot = 0, argvSize, spot = 0,i;




argvSize = strlen(argv[1]);

for (i = 0; i < argvSize; i++)
{

if (argv[1][i] == '/')
{
spot++;

}

}


puts(argv[1]);

for (i = 0; i < argvSize; i++)
{

if (argv[1][i] == '/')
{
if (secSpot != spot)
{
secSpot++;

}
if (secSpot == spot)
{
if (flag == 0)
{
location = i;
flag++;
}
}
}
}


char* UnwantedName = (char*)malloc(NULL); //<--- problem
for (int i = location + 1; i < argvSize; i++)
{
strcat(UnwantedName,"/C2_Mid_Anti-Virus_Project.zip");

}


_flushall();
char* entrenceToTheFolderBefore = (char*)malloc(sizeof(char)*location);

for (int i = 0; i < location; i++)
{
entrenceToTheFolderBefore[i] = argv[1][i];
}

_flushall();
OtherDir = opendir(entrenceToTheFolderBefore);


char* notPath1 = (char*)malloc(NULL);
char* notPath2 = (char*)malloc(NULL);

strcpy(notPath1, argv[1]);
strcpy(notPath2, argv[1]);
strcat(notPath1, "/.");
strcat(notPath2, "/..");


char* InfectedFolderPath = (char*)malloc(NULL);
while (OtherEnt = readdir(OtherDir))
{

if ((strcmp(OtherEnt->d_name, UnwantedName) != 0 && (strcmp(UnwantedName, notPath1) != 0) && (strcmp(UnwantedName, notPath2) != 0)))
{
strcpy(InfectedFolderPath, entrenceToTheFolderBefore);
strcat(InfectedFolderPath, "/");
strcat(InfectedFolderPath, OtherEnt->d_name);
puts(InfectedFolderPath);

}

}

free(UnwantedName);
free(entrenceToTheFolderBefore);
free(InfectedFolderPath);
free(notPath1);
free(notPath2);
}
AnswerRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 20:58
mveRichard MacCutchan23-May-15 20:58 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 23:05
a random user23-May-15 23:05 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 23:19
a random user23-May-15 23:19 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 2:08
a random user24-May-15 2:08 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan24-May-15 2:19
mveRichard MacCutchan24-May-15 2:19 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 2:51
a random user24-May-15 2:51 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan24-May-15 3:08
mveRichard MacCutchan24-May-15 3:08 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 4:08
a random user24-May-15 4:08 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 5:17
a random user24-May-15 5:17 
GeneralRe: C language Help using Dirent.h Pin
David Crow26-May-15 2:53
David Crow26-May-15 2:53 
GeneralRe: C language Help using Dirent.h Pin
David Crow26-May-15 2:51
David Crow26-May-15 2:51 
QuestionRe: C language Help using Dirent.h Pin
David Crow26-May-15 3:49
David Crow26-May-15 3:49 
QuestionRe: C language Help using Dirent.h Pin
David Crow26-May-15 2:48
David Crow26-May-15 2:48 
QuestionCString with non display characters Pin
ForNow22-May-15 6:00
ForNow22-May-15 6:00 
SuggestionRe: CString with non display characters Pin
Richard MacCutchan22-May-15 7:15
mveRichard MacCutchan22-May-15 7:15 
GeneralRe: CString with non display characters Pin
ForNow22-May-15 7:55
ForNow22-May-15 7:55 
AnswerRe: CString with non display characters Pin
Richard Andrew x6422-May-15 12:26
professionalRichard Andrew x6422-May-15 12:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.