|
|
![]() |
|
|
Top | #1 |
|
format c:
Joined: December 2002
Location: Southern California
Posts: 1,358
Reputation: 50
Power: 125 |
i'm trying to pass "userName" string to different functions for logging errors but i seem to be having trouble. I have tried numerous ways of looking at this problem and tried the last 2 days to solve it by myself. any suggestions are welcome! help please! ![]() thanks |
|
|
|
|
|
Top | #2 |
|
OSNN Veteran Addict
Joined: March 2002
Location: United Kingdom
Posts: 7,805
Reputation: 1490
Power: 213 |
You want to use something like this
Code:
void barf(std::string & narf)
{
std::cout << "Stringy is " << narf << std::endl;
}
tring and calling using something likeCode:
int main()
{
std::string peep = "Hello there world";
barf(peep);
}
|
|
|
|
|
|
Top | #3 |
|
format c:
Joined: December 2002
Location: Southern California
Posts: 1,358
Reputation: 50
Power: 125 |
1>emp_strainer_1.cpp(252) : error C2664: 'sortRecords' : cannot convert parameter 14 from 'std:
tring' to 'std: tring []'that's the error message. |
|
|
|
|
|
Top | #4 |
|
OSNN Veteran Addict
Joined: March 2002
Location: United Kingdom
Posts: 7,805
Reputation: 1490
Power: 213 |
are you actually trying to pass in an array of strings?
the std: tring wholly represents a string unlike a char[]. If you are trying to pass in an array though you need to accept a pointer to the first element of the array and possibly another parameter stating the length of the array unless it can be determined some other way. Character array based strings for example have a '\0' character at the end which can be found so you don't need to pass in the array length.
|
|
|
|
|
|
Top | #5 |
|
*
Joined: December 2001
Location: USA
Posts: 6,490
Reputation: 2808
Power: 217 |
I have no clue what you are trying to accomplish, please let me know what you are trying to do.
|
|
|
|
|
|
Top | #6 |
|
format c:
Joined: December 2002
Location: Southern California
Posts: 1,358
Reputation: 50
Power: 125 |
passing the array userName[1] to all my functions. It is an array of 1 string. I am using a string because I do not want to "return" anything in my function.
the program keeps thinking it is a regular string and that i am converting it to a array nevermind, i took that out of the program. i wasted too much time on it. thanks for suggestions. |
|
|
|
|
|
Top | #7 |
|
Penguin Rancher
Joined: February 2002
Location: Elizabethton, TN
Posts: 280
Reputation: 180
Power: 125 |
In your prototype for the mainMenu function, you have userName specified as a string and not an array:
...double tRate[],int flagReadRecords,string userName... But when you try to pass it to the readRecords function, that function prototype is expecting an array. ...int menuExit[],int flagReadRecords,string userName[]... |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SQL - delete string inside of cell, not row. | dubstar | Web Design & Coding | 2 | May 11th, 2006 3:28am |
| Search string length | SPeedY_B | Site Problems & Feedback | 6 | January 14th, 2004 5:42am |
| Visual Basic String Manipulation | cpugeniusmv | Web Design & Coding | 8 | April 29th, 2003 12:36am |
| modem string | bluzeboy | Windows Desktop Systems | 2 | November 22nd, 2002 3:49pm |
| modem string | bluzeboy | Windows Desktop Systems | 3 | September 20th, 2002 3:08am |