小编use*_*863的帖子

在c#中使用重定向(">>")时如何使用String [] args?

我有一个程序test.exe接收参数并将一些日志写入我作为输入提供的特定.txt路径中.我想添加这个命令:

text.exe /r >> textFile.txt 
Run Code Online (Sandbox Code Playgroud)

意思是:构建项目并将日志写入textFile.txt(不存在)我不确定它是如何工作的?是args[2] = ">>"args[3] = textFile.txt?我怎么能用它的名字?困惑!

编辑:当我正在调试并查看我看到的本地人时,/r>> textFile.txt根本没有出现.我如何从命令行获取它作为参数?

编辑2:

理解它应该自动重定向,但是当我这样做时它只是失败并将我发送到一条线:Console.CursorLeft = 0;这意味着当我没有控制台时,我正试图用光标做些事......只是.文本

谢谢!

c# debugging redirect command-line-arguments

3
推荐指数
1
解决办法
108
查看次数

C中的extern声明和头文件

我在这里看到这个问题: 如何使用extern在源文件之间共享变量? 按照手册.但我仍然得到链接器错误...很想得到一些帮助和解释为什么它发生..

我有2个.c文件和一个头文件:

------ check.h ----

#ifndef check
#define check

extern int num;

 #endif
Run Code Online (Sandbox Code Playgroud)

---- ---- check.c

   #include "check.h"
   #include <stdio.h>



   int func(int x, int y)
   {
int z = x+y;
return z;
   }
   void printnum()
   {
num++;
printf("%d",num);
   }
Run Code Online (Sandbox Code Playgroud)

---- ---- ynnynyny.c

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
#include "check.h"
#include "check.c"


int num = 10;
int main() 
{ 
printf("num before is : %d\n",num);
printnum();
printf("num now is : %d",num);
getchar();


return 0; 
}
Run Code Online (Sandbox Code Playgroud)

我一直收到这些错误:

1> …
Run Code Online (Sandbox Code Playgroud)

c declaration global-variables extern

2
推荐指数
1
解决办法
2193
查看次数

如何在linux中测量时间?

我想在给定时间参数时将数据写入文件:例如,我得到x = 7 - >意味着在接下来的7秒内将一些随机数据写入文件我遇到了一些困难,我尝试过使用:clock( )和struct timeval但它不起作用

我试过的事情:

struct timeval start, end;
gettimeofday(&start, 0);
while(  gettimeofday(&end, 0) && end.tv_sec - start.tv_sec < sec )
  {
    write....
  }
Run Code Online (Sandbox Code Playgroud)

但它会停止时钟..

我很乐意得到一些帮助.谢谢

c linux timer

2
推荐指数
1
解决办法
633
查看次数