Homework help (Beginner Level)

B

bd

I keep getting this error:

line(28): error C2664: 'convertString' : cannot convert parameter 1
from 'std::string [26]' to 'std::string'

Here is my code:
//
************************************************************************************************
// This program will take an inputted word from cin and output the
corresponding International
// Civil Aviation Organization(ICAO) words.
//
************************************************************************************************
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

string ICAO[] =
{"Alpha","Bravo","Charlie","Delta","Echo","Foxtrot","Golf","Hotel","India","Juliet","Kilo","Lima","Mike","November","Oscar","Papa","Quebec","Romeo","Sierra","Tango","Uniform","Victor","Whiskey","X-
ray","Yankee","Zulu"};

// Function prototype
void convertString(string ICAO, string inputString);

//
************************************************************************************************
int main()
{
string inputString;

cout << "Enter string: ";
cin >> inputString;

cout << "\nPhonetic version is: " << convertString( ICAO,
inputString);

cin.get();
cin.get();
return 0;
}
//
************************************************************************************************
void convertString( /*in*/ string inputString,
/*in*/ string ICAO[] )

{
char tempChar;
int tempInt;

// Capitalize inputString
for(unsigned int i=0; i<inputString.length(); i++)
{
inputString = (toupper(inputString));
};

for(unsigned int i=0; i<inputString.length(); i++)
{
tempChar = inputString;
tempInt = tempChar - 30;
cout << ICAO[tempInt];
};
return;
}



Any ideas?

Thanks,
Dale
 
A

AnonMail2005

I keep getting this error:

line(28): error C2664: 'convertString' : cannot convert parameter 1
from 'std::string [26]' to 'std::string'

Here is my code:
//
***************************************************************************­*********************
// This program will take an inputted word from cin and output the
corresponding International
// Civil Aviation Organization(ICAO) words.
//
***************************************************************************­*********************
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

string ICAO[] =
{"Alpha","Bravo","Charlie","Delta","Echo","Foxtrot","Golf","Hotel","India",­"Juliet","Kilo","Lima","Mike","November","Oscar","Papa","Quebec","Romeo","S­ierra","Tango","Uniform","Victor","Whiskey","X-
ray","Yankee","Zulu"};

// Function prototype
void convertString(string ICAO, string inputString);

//
***************************************************************************­*********************
int main()
{
string inputString;

cout << "Enter string: ";
cin >> inputString;

cout << "\nPhonetic version is: " << convertString( ICAO,
inputString);

cin.get();
cin.get();
return 0;}

//
***************************************************************************­*********************
void convertString( /*in*/ string inputString,
/*in*/ string ICAO[] )

{
char tempChar;
int tempInt;

// Capitalize inputString
for(unsigned int i=0; i<inputString.length(); i++)
{
inputString = (toupper(inputString));
};

for(unsigned int i=0; i<inputString.length(); i++)
{
tempChar = inputString;
tempInt = tempChar - 30;
cout << ICAO[tempInt];
};
return;

}

Any ideas?

Thanks,
Dale

Your convertString function takes a std::string as it's first arg
but you are passing an array of strings.
 
B

bwhartbeck

A couple for you ... look at the forward declaration of the
convertString function, the use of the convertString function within
main and the implementation of convertString ... particularly the
input parameters and their order. I have not looked at the logic of
what you are doing ... so that may still need work.

Enjoy
 
R

red floyd

bd said:
I keep getting this error:

line(28): error C2664: 'convertString' : cannot convert parameter 1
from 'std::string [26]' to 'std::string'

Here is my code:
//
************************************************************************************************
// This program will take an inputted word from cin and output the
corresponding International
// Civil Aviation Organization(ICAO) words.
//
************************************************************************************************
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

string ICAO[] =
{"Alpha","Bravo","Charlie","Delta","Echo","Foxtrot","Golf","Hotel","India","Juliet","Kilo","Lima","Mike","November","Oscar","Papa","Quebec","Romeo","Sierra","Tango","Uniform","Victor","Whiskey","X-
ray","Yankee","Zulu"};

// Function prototype
void convertString(string ICAO, string inputString);

//
************************************************************************************************
int main()
{
string inputString;

cout << "Enter string: ";
cin >> inputString;

cout << "\nPhonetic version is: " << convertString( ICAO,
inputString);

cin.get();
cin.get();
return 0;
}
//
************************************************************************************************
void convertString( /*in*/ string inputString,
/*in*/ string ICAO[] )
Look at your prototype. Look at the footprint of this method. Do they
match? Now look at the error message.
{
char tempChar;
int tempInt;

// Capitalize inputString
for(unsigned int i=0; i<inputString.length(); i++)
{
inputString = (toupper(inputString));
};

for(unsigned int i=0; i<inputString.length(); i++)
{
tempChar = inputString;
tempInt = tempChar - 30;
cout << ICAO[tempInt];
};
return;
}



Any ideas?

Thanks,
Dale
 
P

patelvijayp

I keep getting this error:

line(28): error C2664: 'convertString' : cannot convert parameter 1
from 'std::string [26]' to 'std::string'

Here is my code:
//
************************************************************************************************
// This program will take an inputted word from cin and output the
corresponding International
// Civil Aviation Organization(ICAO) words.
//
************************************************************************************************
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

string ICAO[] =
{"Alpha","Bravo","Charlie","Delta","Echo","Foxtrot","Golf","Hotel","India","Juliet","Kilo","Lima","Mike","November","Oscar","Papa","Quebec","Romeo","Sierra","Tango","Uniform","Victor","Whiskey","X-
ray","Yankee","Zulu"};

// Function prototype
void convertString(string ICAO, string inputString);

//
************************************************************************************************
int main()
{
string inputString;

cout << "Enter string: ";
cin >> inputString;

cout << "\nPhonetic version is: " << convertString( ICAO,
inputString);

cin.get();
cin.get();
return 0;}

//
************************************************************************************************
void convertString( /*in*/ string inputString,
/*in*/ string ICAO[] )

{
char tempChar;
int tempInt;

// Capitalize inputString
for(unsigned int i=0; i<inputString.length(); i++)
{
inputString = (toupper(inputString));
};

for(unsigned int i=0; i<inputString.length(); i++)
{
tempChar = inputString;
tempInt = tempChar - 30;
cout << ICAO[tempInt];
};
return;

}

Any ideas?

Thanks,
Dale


1) Function prototype says,
// Function prototype
void convertString(string ICAO, string inputString);
first argument is string, (variable name ICAO -- is just for your
understanding.).
second argument is also string.

2) Calling line...
cout << "\nPhonetic version is: " << convertString( ICAO,
inputString);
first argument is ICAO -- that is string [] -- string array!

So, compiler found prototype of string. But when u are calling
function, compiler got ICAO -- as string [26] (26 strings in array!).

Vijay.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top