被调用的对象 'strn' 不是一个函数

标签 c arrays function compiler-errors

编译以下代码时出现错误

"called object strn is not a function"

厌倦了这个错误!需要一个解决方案!!

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define num 400
int main()
{
    char strn[num];
    int count;
    int a=0,e=0,i=0,o=0,u=0;
    printf("enter your string!\n");
    gets(strn);
    for(count=0;count<strlen(strn);count++)
    {
        if ( strn(count)=='a' )
        {
            a++;
        }
        if (strn(count)=='e')
        {
            e++;
        }

最佳答案

您正在尝试将 strn 用作函数:strn(count)

您可能正在尝试访问 count 索引处的值,因此您应该使用 strn[count]

关于被调用的对象 'strn' 不是一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30070458/

相关文章:

C - if-else 语句卡住并崩溃

c++ - 跟踪 C 中的整数列表,并从列表中采样

r - 对向量列表应用平均值的函数,无需列出向量(对函数调用的更改)

r - 测试 R 中是否设置了函数的参数

c - 从 ASM 返回一个 int*

C 代码不能在 Linux 上运行,但可以在 Mac 上运行

java - 在类数组中使用 'contains' 方法

php - 如何将数组的json对象转换为php数组

python - 如何轻松地将 numpy.ndarray 转换为 numpy.array 列表?

C++:评估自己的数学函数(像多维分析一样的函数数组)entry-wise