edit:
gotcha!
Code:
s = malloc(strlen(argv[1]) * sizeof(char));
Good afternoon friends. How can I malloc argv in main?
Code:
#include <stdio.h>
#include <stdlib.h> /* for exit() */
#include <string.h>
void Strcpy(char*, char*);
void Strcpy(char* s, char* t)
{
while ( (*s++ = *t++) )
;
}
int main(int argc, char** argv)
{
char* s = malloc(strlen(argv) * sizeof(char));
if(argc < 2)
{
printf("Please enter [Executable][string]\n");
exit(0);
}
Strcpy(s, *(argv + 1));
printf("Clone is %s\n", s);
free(s);
return 0;
}