Connecting Tech Pros Worldwide Help | Site Map

Homework help (Beginner Level)

  #1  
Old April 21st, 2007, 10:45 PM
bd
Guest
 
Posts: n/a
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","M ike","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[i] = (toupper(inputString[i]));
};

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



Any ideas?

Thanks,
Dale

  #2  
Old April 21st, 2007, 11:05 PM
AnonMail2005@gmail.com
Guest
 
Posts: n/a

re: Homework help (Beginner Level)


On Apr 21, 5:39 pm, bd <dalestubblefi...@gmail.comwrote:
Quote:
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[i] = (toupper(inputString[i]));
};
>
for(unsigned int i=0; i<inputString.length(); i++)
{
tempChar = inputString[i];
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.

  #3  
Old April 21st, 2007, 11:05 PM
bwhartbeck@sbcglobal.net
Guest
 
Posts: n/a

re: Homework help (Beginner Level)


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

On Apr 21, 2:39 pm, bd <dalestubblefi...@gmail.comwrote:
Quote:
I keep getting this error:
>
line(28): error C2664: 'convertString' : cannot convert parameter 1
from 'std::string [26]' to 'std::string'
>
<snip>
// Function prototype
void convertString(string ICAO, string inputString);
<snip>
>
cout << "\nPhonetic version is: " << convertString( ICAO,
inputString);
>
><snip>
void convertString( /*in*/ string inputString,
/*in*/ string ICAO[] )
>

  #4  
Old April 21st, 2007, 11:15 PM
red floyd
Guest
 
Posts: n/a

re: Homework help (Beginner Level)


bd wrote:
Quote:
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","M ike","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[] )
Look at your prototype. Look at the footprint of this method. Do they
match? Now look at the error message.
Quote:
>
{
char tempChar;
int tempInt;
>
// Capitalize inputString
for(unsigned int i=0; i<inputString.length(); i++)
{
inputString[i] = (toupper(inputString[i]));
};
>
for(unsigned int i=0; i<inputString.length(); i++)
{
tempChar = inputString[i];
tempInt = tempChar - 30;
cout << ICAO[tempInt];
};
return;
}
>
>
>
Any ideas?
>
Thanks,
Dale
>
  #5  
Old April 23rd, 2007, 07:35 AM
patelvijayp
Guest
 
Posts: n/a

re: Homework help (Beginner Level)


On Apr 22, 2:39 am, bd <dalestubblefi...@gmail.comwrote:
Quote:
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","M ike","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[i] = (toupper(inputString[i]));
};
>
for(unsigned int i=0; i<inputString.length(); i++)
{
tempChar = inputString[i];
tempInt = tempChar - 30;
cout << ICAO[tempInt];
};
return;
>
}
>
Any ideas?
>
Thanks,
Dale
1) Function prototype says,
Quote:
// 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...
Quote:
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.

  #6  
Old April 30th, 2007, 02:45 PM
bd
Guest
 
Posts: n/a

re: Homework help (Beginner Level)


I did get this figured out eventually.

I appreciate everyone's assistance!

Thanks!

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to save text data in my programme sirimanna answers 6 April 11th, 2007 06:30 AM
hey.. help! plz... i nid ur response about this assignment tao_from_heaven@yahoo.com answers 5 March 9th, 2007 05:15 PM
Starting University COSC and learning JAVA, advice please :D David Van D answers 1 February 4th, 2006 02:45 AM
The Demise of the Art of Programming Kevin Spencer answers 42 November 19th, 2005 08:59 AM