c - 获取 "warning:assignment from incompatible pointer type"

标签 c

我在 fp=fopen("task.txt","r") 处收到错误,有人可以帮我吗?
我正在尝试使用 fp(文件指针)

打开文件
main()
{
    int l=0,pr[100];
    FILE *fp;
    fp=("task.txt","r");
    if(fp==NULL)
    printf("No file found");
    char arr[100][20];
    const char *str;int i;
    while(fscanf(fp,"%s",str)!=EOF)
    {
        strcpy(arr[l],str);
        l++;
    }
    for(i=0;i<l;i++)
    {
        system(arr[i]);
    }
}

最佳答案

你的代码没有这样的行。再次检查您的代码。

你写的时候没有使用 fopen

fp=("task.txt","r");

写这个

fp=fopen("task.txt","r");

你会得到它

关于c - 获取 "warning:assignment from incompatible pointer type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43493140/

相关文章:

c - 字符指针数组函数如何实现?

c - 在 c 中使用套接字时,FD_SET 和 FD_ISSET 背后的数据结构是什么?

c - 从服务器向客户端发送消息

c - 更改指针是否被视为 C 中的原子操作?

c - 使用 swapcontext() 或 getcontext() & setcontext() 为线程库编写 yield() 函数

android - NFC P2P as3911 <--> 手机

c - 如何删除所有可能的二叉树节点?

c - C 中的 2D 环形缓冲区

c - 对指向指针 "array"的指针的单个 malloc 调用导致无效写入

c - ncurses、面板、光标位置和轮询 STDIN