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 8933881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:39:02+00:00 2026-06-15T09:39:02+00:00

My program was working fine with the main function at the end, but when

  • 0

My program was working fine with the main function at the end, but when I added in the function prototyping and put the main function in the beginning I started to get these errors.

error C2664: ‘getData’ : cannot convert parameter 1 from ‘std::string
[100]’ to ‘std::string’ No constructor could take the source type, or
constructor overload resolution was ambiguous

error C2664: ‘descending’ : cannot convert parameter 1 from
‘std::string [100]’ to ‘std::string’ No constructor could take the
source type, or constructor overload resolution was ambiguous

error C2664: ‘ascending’ : cannot convert parameter 1 from
‘std::string [100]’ to ‘std::string’ No constructor could take the
source type, or constructor overload resolution was ambiguous

error C2664: ‘output’ : cannot convert parameter 1 from ‘std::string
[100]’ to ‘std::string’

No constructor could take the source type, or constructor overload resolution was ambiguous

#include <iostream>
#include <string>
#include <fstream>
using namespace std;

void swap(string&, string&);
void getData(string, int&);
void ascending(string, int);
void descending(string, int);
void output(string, int);
int getChoice();

int main()
{
   string name[100], temp;
   int item, choice;

   getData(name, item);

   choice = getChoice();

   if (choice == 1)
      ascending(name, item);
   if (choice == 2)
      descending(name, item);

   output(name, item);
 }



void swap(string& name1, string& name2)
{
   string temp;
   temp  = name1;
   name1 = name2;
   name2 = temp;
}


void getData(string name[], int& item)
{
   ifstream  fin;
   fin.open("E:\\p9.txt");

   item = 0;

   while (!fin.eof())
   {
      fin >> name[item];
      item++;    
   }
   cout << "item = " << item << endl << endl;
}

void ascending(string name[], int item)
{
   for(int j=0; j<item-1; j++)
   {
      for(int i=0; i<item-1; i++)
         if(name[i] > name[i+1])
            swap(name[i], name[i+1]);
   }
}

void descending(string name[], int item)
{
   string temp;
   for(int j=0; j<item-1; j++)
   {
      for(int i=0; i<item-1; i++)
         if(name[i] < name[i+1])
            swap(name[i], name[i+1]);
   }
}




void output(string name[], int item)
{
   for(int i=0; i<item; i++)
      cout << name[i] << endl;
   cout << endl << endl;
}

int getChoice()
{
   int choice;
   cout << "Please enter 1 for ascending or 2 for descending." << endl;
   cin  >>  choice;
   return choice;
}
  • 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-06-15T09:39:03+00:00Added an answer on June 15, 2026 at 9:39 am

    Well, your “prototypes” don’t match your function definitions. Why did you introduce prototypes that have no relation to the actual functions?

    Here’s one example

    void getData(string, int&);
    
    void getData(string name[], int& item) { ... }
    

    The correct “prototype” in this case is

    void getData(string[], int&);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some time ago I started working on OpenGL(3.3) renderer for MFC program.Everything was fine
I am using Junit 4. My whole program is working fine. I am trying
I'm working on a socket program and everything seems fine when compiling. First I
I'm trying to get a simple winsock program working, so I create my socket
I'm trying to get a helloworld type program working with REST CI/jquery. I've included
I'm using Visual studio c++ 2010. My program was working fine until I linked
I'm trying to compile/run my program (which is working fine on Windows/MSVC) on Fedora/gcc.
I'm writing a program that calls a function in main that creates a node
All my OpenCV functions are working perfectly fine. But cvResize() is not found by
My GDI program runs fine on Windows XP but on Windows Vista and 7

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.