相关疑难解决方法(0)

为什么获取功能如此危险以至于不应该使用它?

当我尝试编译使用gets()GCC函数的C代码时,

我明白了

警告:

(.text + 0x34):警告:`gets'函数很危险,不应该使用.

我记得这与堆栈保护和安全性有关,但我不确定为什么?

有人可以帮我删除这个警告并解释为什么会有这样的使用警告gets()

如果gets()是如此危险,为什么我们不能删除它?

c gets fgets buffer-overflow

210
推荐指数
9
解决办法
14万
查看次数

如何使用S_ISREG()和S_ISDIR()POSIX宏?

这是我写的一个C程序,用于递归导航和输出目录和常规文件.它在我的Linux机器上编译并运行良好.但是在Solaris上,dit->d_type == 8检查和其他类似检查不起作用,因为没有d_type字段.我已经阅读过这个问题的答案是使用S_ISREG()S_ISDIR()宏,但它们并不能完全按照我目前的代码中的方式工作.我注释掉了在我的Linux机器上运行的行.

#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <dirent.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>

void helper(DIR *, struct dirent *, struct stat, char *, int, char **);
void dircheck(DIR *, struct dirent *, struct stat, char *, int, char **);

int main(int argc, char *argv[]){

  DIR *dip;
  struct dirent *dit;
  struct stat statbuf;
  char currentPath[FILENAME_MAX];
  int depth = 0; /*Used to correctly space output*/

  /*Open Current Directory*/ …
Run Code Online (Sandbox Code Playgroud)

c solaris stat readdir

11
推荐指数
2
解决办法
9万
查看次数

如何在不使用删除系统调用的情况下使用C程序删除(完全删除)文件?

我一直很好奇remLinux在工作中如何编写我自己的C代码可以删除文件但是当我搜索答案时,我只得到了使用remove()系统调用的程序.

有没有其他方法可以不使用系统调用来编写自己的代码来完成这项工作?

我已经完成了通过C文件复制文件但无法找到通过C删除文件的解决方案.

c linux ubuntu-12.04

5
推荐指数
2
解决办法
2万
查看次数

标签 统计

c ×3

buffer-overflow ×1

fgets ×1

gets ×1

linux ×1

readdir ×1

solaris ×1

stat ×1

ubuntu-12.04 ×1