I have been working with system() and I need to use the code below but as you know system() only provides one argument so please help!!
|
sys=system ("unzip -P ", str, " /Users/student/Desktop/Else/C:C++/passzip.zip");
|
Last edited on
system("unzip -P " + str + " /Users/student/Desktop/Else/C:C++/passzip.zip");
error: invalid operands to binary
expression ('char *' and 'char *')
change str to string(str)
no, system() only works with one argument... it sucks
here's my whole code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static const char alphabet[] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";
static const int alphabet_size = sizeof(alphabet) - 1;
void brute_impl(char * str, int index, int max_depth)
{
int i;
int sys;
for (i = 0; i < alphabet_size; ++i)
{
str[index] = alphabet[i];
if (index == max_depth - 1)
{
printf("\nTrying %s", str);
system("unzip -P ", str, " /Users/student/Desktop/Else/C:C++/passzip.zip");
}
else
{
brute_impl(str, index + 1, max_depth);
}
}
}
void brute_sequential(int max_len)
{
char * buf = malloc(max_len + 1);
int i;
for (i = 1; i <= max_len; ++i)
{
memset(buf, 0, max_len + 1);
brute_impl(buf, 0, i);
}
free(buf);
}
int main(void)
{
brute_sequential(3);
return 0;
}
|
Last edited on
You're writing this in C?