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 5 1936
On Apr 21, 5:39 pm, bd <dalestubblefi...@gmail.comwrote:
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.
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:
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[] )
bd wrote:
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.
>
{
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
On Apr 22, 2:39 am, bd <dalestubblefi...@gmail.comwrote:
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,
// 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.
I did get this figured out eventually.
I appreciate everyone's assistance!
Thanks! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Richard B. Kreckel |
last post by:
Hi!
I was recently asked what book to recommend for a beginner in C++. I
am convinced that you needn't study C in depth before learning C++
(though it helps), but cannot find any beginner's...
|
by: lester |
last post by:
a pre-beginner's question:
what is the pros and cons of .net, compared to ++
I am wondering what can I get if I continue to learn C# after I have learned
C --> C++ --> C# ??
I think there...
|
by: tjshadyluver |
last post by:
ok i have gotten this damn project almost done but i am frustrated on
this one step. getting 18-35 together and 36-50 and so on. here is my
code how can i get them combined in one line instead of...
|
by: N3TB1N |
last post by:
Here is my assignment. I am hoping that someone here quickly knows
all of the correct answers... especially for question #5 and
everything after. Thanks in advance.
...
|
by: N3TB1N |
last post by:
Let me try again. I could use some help with this assignment, even
though my teacher does not grade assignments.but because I need to
know this stuff for a test very soon, but haven't been in...
|
by: Blaze |
last post by:
I am doing the first walk through on the Visual Studio .Net walkthrough book
to learn a little about programming. I am having issues with the first
tutorial not running correctly. It seems that...
|
by: Joshua Rulz |
last post by:
Hi, i want to learn to program im quite skilled with computers and want
to learn c++. is there anyone who can teach me or tell me a good
website to learn it?
all replies will be appreciated.
|
by: mitchellpal |
last post by:
Hi guys, am learning c as a beginner language and am finding it rough
especially with pointers and data files. What do you think, am i being
too pessimistic or thats how it happens for a beginner?...
|
by: R.A.M. |
last post by:
Hello,
I am trying to learn SQL Server. I need to write a trigger which
deletes positions of the document depending on the movement type.
Here's my code:
set ANSI_NULLS ON
set...
|
by: Matt |
last post by:
I've coded using VBA on top of MS Excel for the last 2 years (40 hours a
week). I've stepped up to VS C# 2005 Express / SQL Server 2005 Express a
couple months ago, but the videos that I downloaded...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |