testing-repository/c/args.c

20 lines
369 B
C
Raw Normal View History

2021-09-23 07:38:25 +08:00
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc,char **argv){
const char * src = *argv;
int len = strlen(src); //argv[0]
char * tmp = malloc(len);
2021-09-23 14:09:32 +08:00
#ifdef _WIN32
strncpy(tmp,src,len-8);
tmp[len-8]='\0';
#else
2021-09-23 07:38:25 +08:00
strncpy(tmp,src,len-4);
2021-09-23 14:09:32 +08:00
tmp[len-4]='\0';
#endif
2021-09-23 07:38:25 +08:00
printf("%s\n",tmp);
free(tmp);
return 0;
}