Click here to Skip to main content
14,325,129 members

C / C++ / MFC

 
AnswerRe: C language Help using Dirent.h Pin
k505422-May-15 7:37
memberk505422-May-15 7:37 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 1:06
membera random user23-May-15 1:06 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 2:15
protectorRichard MacCutchan23-May-15 2:15 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 2:56
membera random user23-May-15 2:56 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 3:04
protectorRichard MacCutchan23-May-15 3:04 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 3:08
membera random user23-May-15 3:08 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 3:45
membera random user23-May-15 3:45 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 6:27
protectorRichard MacCutchan23-May-15 6:27 
Sorry, but that code does not make any sense. I have no idea what the first block of code is supposed to be doing. And in the code following the flushall call, you have made a call to strlen on a pointer returned from malloc. But the memory that it points to has not been initialised with a string, so the value you get will be either zero, or some random invalid number. You must use strlen on the source string (argv[1]) in order to measure it. So your code should be something like:
int length = strlen(argv[1]) + 1; // extra space for trailing null character
char* entrenceToTheFolderBefore = (char*)malloc(sizeof(char) * length);
for (int i = 0; i < length; i++)
{
    entrenceToTheFolderBefore[i] = argv[1][i];
}

You could use strcpy here, but perhaps your teacher has told you not to.
QuestionRe: C language Help using Dirent.h Pin
a random user23-May-15 9:47
membera random user23-May-15 9:47 
AnswerRe: C language Help using Dirent.h Pin
Richard MacCutchan23-May-15 20:58
protectorRichard MacCutchan23-May-15 20:58 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 23:05
membera random user23-May-15 23:05 
GeneralRe: C language Help using Dirent.h Pin
a random user23-May-15 23:19
membera random user23-May-15 23:19 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 2:08
membera random user24-May-15 2:08 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan24-May-15 2:19
protectorRichard MacCutchan24-May-15 2:19 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 2:51
membera random user24-May-15 2:51 
GeneralRe: C language Help using Dirent.h Pin
Richard MacCutchan24-May-15 3:08
protectorRichard MacCutchan24-May-15 3:08 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 4:08
membera random user24-May-15 4:08 
GeneralRe: C language Help using Dirent.h Pin
a random user24-May-15 5:17
membera random user24-May-15 5:17 
GeneralRe: C language Help using Dirent.h Pin
David Crow26-May-15 2:53
memberDavid Crow26-May-15 2:53 
GeneralRe: C language Help using Dirent.h Pin
David Crow26-May-15 2:51
memberDavid Crow26-May-15 2:51 
QuestionRe: C language Help using Dirent.h Pin
David Crow26-May-15 3:49
memberDavid Crow26-May-15 3:49 
QuestionRe: C language Help using Dirent.h Pin
David Crow26-May-15 2:48
memberDavid Crow26-May-15 2:48 
QuestionCString with non display characters Pin
ForNow22-May-15 6:00
memberForNow22-May-15 6:00 
SuggestionRe: CString with non display characters Pin
Richard MacCutchan22-May-15 7:15
protectorRichard MacCutchan22-May-15 7:15 
GeneralRe: CString with non display characters Pin
ForNow22-May-15 7:55
memberForNow22-May-15 7:55 

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.