非main函数中获取 命令行参数
This commit is contained in:
38
cmdline_test.c
Normal file
38
cmdline_test.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "stdio.h"
|
||||
#include "stdint.h"
|
||||
#include "soft/debug.h"
|
||||
#include "stddef.h"
|
||||
|
||||
|
||||
|
||||
|
||||
int get_argv(char** argv[]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void save_data(const char *filename,const uint8_t *buff,uint32_t size)
|
||||
{
|
||||
FILE* fp;
|
||||
fp = fopen(filename, "wb");
|
||||
fwrite(buff, size, 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int thread_fun(void* t) {
|
||||
int argc;
|
||||
char** argv;
|
||||
char buff[10240] = { 0 };
|
||||
int index = 0;
|
||||
argc = get_argv(&argv);
|
||||
DBG_LOG("argc=%d, ",argc);
|
||||
for (int i = 0;i < argc;i++) {
|
||||
DBG_LOG("%s", argv[i]);
|
||||
index += sprintf(&buff[index],"%s ", argv[i]);
|
||||
}
|
||||
save_data("argv.log", buff, index);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user