c - Linux 终端文件打开

标签 c linux file terminal

这是我写的一些代码,但我对如何使用 linux 终端运行它感到困惑。 我试过这样写: asdasd:~/folder/file>./main.c file.txt 但我一直被拒绝许可。 我需要一些其他程序来运行它吗?我希望我提供了足够的信息以获得某种反馈

(file.txt 是我试图启动程序的文件)

...........
void fileReader(int number, char *vector[])
{
    if(number!= 2)
    {
        printf("File: %s filename\n", vector[0]);
        exit(1);
    }
    FILE *file = fopen(vector[1], "r");
    if(file == 0)
    {
        printf("File cannot be opened\n");
        exit(1);
    }
..........
........

最佳答案

你必须编译程序。

你这样做

gcc main.c -o program

然后你开始:

./program file.txt

关于c - Linux 终端文件打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25568049/

相关文章:

python - 我无法在 Windows 10 的 cmd 中或在 kali linux 的终端中运行 .py 文件

linux - 使用 ocf :pacemaker:ClusterMon and/or external-agent 监控起搏器集群

java - 使用谷歌云存储中的文件

linux - 文件的标准错误;但没有缓冲

c - 为什么 substring 不是 C 标准库的一部分?

c++ - 在 C/C++ 中声明和使用 FILE * 指针的正确方法是什么?

c - 如何将 char 大小的二进制有符号数扩展为有符号 int 大小

c - 使用 CURL 测试时,我的 C 程序在接受连接时被卡住

linux - 如何检查字符串是否以特定字符串开头>

PHP + MySQL : File reading limit and connection error