Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7414081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:00:06+00:00 2026-05-29T07:00:06+00:00

I have an error in my program which says that ‘count’ cannot be used

  • 0

I have an error in my program which says that
‘count’ cannot be used as a function.

it points to the below line

mycount = (int) count (t1q1.begin(), t1q1.end(), 1);

i have already included algorithm, using namespace std, but still it shows the error.

This is what I do with my vector t1q1
The below code allows the program to read in the file and extract the certain information and push it back to the vector

MY FUNCTION TO READ FILE AND STORE IT IN VARIABLES

void checkForAnswers(char *ptr)
{
    char String[256];
    int count = 0;

    while ( *ptr != ':')
    {
        String[count] = *ptr;
        ptr++;
        count++;
    }

    String[count] = '\0';

     //if topic is 1.
     if (strcmp(String, "1") == 0)
    {
         currentPtr=Travels(':',startPtr);
         int answerone1 = (int)atoi(currentPtr);
         currentPtr=Travels(':',currentPtr);
         int answertwo2 = (int)atoi(currentPtr);
         currentPtr=Travels(':',currentPtr);
         int answerthree3 = (int)atoi(currentPtr);
         currentPtr=Travels(':',currentPtr);
         int answerfour4 = (int)atoi(currentPtr);
         currentPtr=Travels(':',currentPtr);
         int answerfive5 = (int)atoi(currentPtr);

         t1q1.push_back(answerone1);
         t1q2.push_back(answertwo2);
         t1q3.push_back(answerthree3);
         t1q4.push_back(answerfour4);
         t1q5.push_back(answerfive5);
    }

    if (strcmp(String, "2") == 0)
    {
        currentPtr=Travels(':',startPtr);
        int answerone1 = (int)atoi(currentPtr);
        currentPtr=Travels(':',currentPtr);
        int answertwo2 = (int)atoi(currentPtr);
        currentPtr=Travels(':',currentPtr);
        int answerthree3 = (int)atoi(currentPtr);
        currentPtr=Travels(':',currentPtr);
        int answerfour4 = (int)atoi(currentPtr);
        currentPtr=Travels(':',currentPtr);
        int answerfive5 = (int)atoi(currentPtr);

        t2q1.push_back(answerone1);
        t2q2.push_back(answertwo2);
        t2q3.push_back(answerthree3);
        t2q4.push_back(answerfour4);
        t2q5.push_back(answerfive5);
    }

     if (strcmp(String, "3") == 0)
     {
        currentPtr=Travels(':',startPtr);
        int answerone1 = (int)atoi(currentPtr);
        currentPtr=Travels(':',currentPtr);
        int answertwo2 = (int)atoi(currentPtr);
        currentPtr=Travels(':',currentPtr);
        int answerthree3 = (int)atoi(currentPtr);
        currentPtr=Travels(':',currentPtr);
        int answerfour4 = (int)atoi(currentPtr);
        currentPtr=Travels(':',currentPtr);
        int answerfive5 = (int)atoi(currentPtr);

        t3q1.push_back(answerone1);
        t3q2.push_back(answertwo2);
        t3q3.push_back(answerthree3);
        t3q4.push_back(answerfour4);
        t3q5.push_back(answerfive5);
    }

        currentPtr=0;
} 

MY MAIN

  char Lines1[256];
        int count1 = 0;

        ifstream resultfile("results.txt");
        if (resultfile.is_open())
        {
            do
            {
            resultfile.getline(Lines1, 256);
            startPtr = Lines1;
            checkForAnswers(startPtr);
            count1++;
            }while(resultfile.eof() == false);
        resultfile.close();
        }


    int mycount;
    cout<< "\n";
    cout<< "TABULATION RESULTS\n";
    cout<< "------------------\n";
    cout<< "Topic 1, Question 1\n";
    mycount = (int) count (t1q1.begin(), t1q1.end(), 1);
    cout<< "Option 1: "<< mycount << " time(s)\n";

Hope you guys will be able to help me out.
Thanks in advance to those who helped!
🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:00:07+00:00Added an answer on May 29, 2026 at 7:00 am

    In your code count refers to the local variable count, which has type int and thus cannot be used as a function. You should name the variable something else or refer to the function using its qualified name std::count.

    Also make sure that you #include <algorithm> (and have an appropriate using declaration if you go the route of renaming the variable and calling the function using its unqualified name).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that spits out both standard error and standard out, and
In my program, I have been receiving an error when I use a command-line
I'm working on a vbscript program and I have got and Expected Statement Error.
I wrote this code I have these errors Cannot implicitly convert type x.Program.TreeNode' to
We have an error that we can't seem to find and don't have the
I have this error message: Msg 8134, Level 16, State 1, Line 1 Divide
I have this error that is keeping me from moving forward. I basically have
You have an error in your SQL syntax; check the manual that corresponds to
Okay here's the program I have typed up(stdio.h is included also): /* function main
I have a question. The problem is that I have another process which invoked

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.