小编Sax*_*owl的帖子

这个符号在我的Unix命令中意味着什么?

我正在做一些教程,我看到这个shell命令:

find / -name foo 2>/dev/null
Run Code Online (Sandbox Code Playgroud)

最后一个令牌是做什么的?具体来说,2?我得到>重定向将shell输出发送到文件,但是如何find只获取错误消息?

unix shell

0
推荐指数
1
解决办法
59
查看次数

使用vscode,当同时包含“ iosteam”和“ stdio.h”时为什么不能编译?

当我同时声明时,vscode无法编译文件,并且出现错误日志:

    > Executing task: C:\mingw64\bin\gcc.exe -g d:\CODES\C++\try\main.cpp -o d:\CODES\C++\try\main.exe <

C:\Users\16337\AppData\Local\Temp\ccqDR0fO.o: In function `__tcf_0':
C:/mingw64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
C:\Users\16337\AppData\Local\Temp\ccqDR0fO.o: In function `__static_initialization_and_destruction_0':
C:/mingw64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/iostream:74: undefined reference to `std::ios_base::Init::Init()'
collect2.exe: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

我的代码很简单:

#include <iostream>
#include <stdio.h>


int main()
{
    printf("print something");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

Dev-C ++可以正确编译该代码。

如果删除#include <iostream>,则可以正确编译。

c compilation mingw-w64

-1
推荐指数
1
解决办法
56
查看次数

如果字符串在C / C ++中没有NUL字符(如果编译器允许它通过),会发生什么?

如果字符串没有NUL字符(\ 0)并且编译器将其传递,例如带有警告,该怎么办?它对计算机和程序有何影响?

c c++ string

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

创建我自己的strdup函数

我不明白为什么在这里我的字符没有被复制,strlen是正确的但我输出了'\n'

char            *my_strdup(char *str)
{
  char          *new_str;
  char          *to_copy;
  int           i;

  to_copy = str;
  i = strlen(str + 1);
  new_str = malloc(sizeof(*new_str) * i + 1);
  while(i - 1 > 0)
    {
      *new_str = *to_copy;
      new_str++;
      to_copy++;
      i--;
    }
  return(new_str);
}
Run Code Online (Sandbox Code Playgroud)

这是我的测试功能:

int             main()
{
  char          *str;

  str = my_strdup("helloo");
  printf("%s\n", str);
}
Run Code Online (Sandbox Code Playgroud)

c pointers

-9
推荐指数
1
解决办法
2691
查看次数

标签 统计

c ×3

c++ ×1

compilation ×1

mingw-w64 ×1

pointers ×1

shell ×1

string ×1

unix ×1