Reply
Old May 21st, 2007 Top | #1
 
dubstar's Avatar
format c:
Joined: December 2002
Location: Southern California
Posts: 1,358
Reputation: 50
Power: 125

Default C++: cant resolve string --> string[]

attached: code in cpp file.

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
Attached Files
File Type: zip Emp_Strainer_1.zip (6.3 KB, 69 views)

QuistPro: 13" macbook pro. mid 2009. 10.6.4

box360: xbox 360 elite

apple airport extreme / fios / 10mb/2mb

retired:

nerdBox: a7n8x-d / xp pro / 2800 athlon xp

quistBox: xbox 1.6b / 250g / xenium ice mod-chip

quistServ: dell pEdge 600sc / 2k3

blackthorne: dell e1505 / mce / 1.83 duo

iQuist: White 3g iPhone / 16g / jailbroken / unlocked TMobile

quistMobile: tmobile mda

quistMobile2: htc g1
dubstar is offline   Reply With Quote
Old May 22nd, 2007 Top | #2

OSNN Folding Team  
Geffy's Avatar
OSNN Veteran Addict
Joined: March 2002
Location: United Kingdom
Posts: 7,805
Reputation: 1490
Power: 213

Default Re: C++: cant resolve string --> string[]

You want to use something like this

Code:
void barf(std::string & narf)
{
    std::cout << "Stringy is " << narf << std::endl;
}
thereby using a reference to a std:tring and calling using something like

Code:
int main()
{
    std::string peep = "Hello there world";
    barf(peep);
}
that kind of thing should work. X-Istence is probably better on C++ then I am at the moment I have been doing pure C for the last couple of weeks.


blogtumbloglastfmflickr#rubyonrails@twitter
"I could be replaced with a very small shell script"
Geffy is offline   Reply With Quote
Old May 22nd, 2007 Top | #3
 
dubstar's Avatar
format c:
Joined: December 2002
Location: Southern California
Posts: 1,358
Reputation: 50
Power: 125

Default Re: C++: cant resolve string --> string[]

1>emp_strainer_1.cpp(252) : error C2664: 'sortRecords' : cannot convert parameter 14 from 'std:tring' to 'std:tring []'

that's the error message.

QuistPro: 13" macbook pro. mid 2009. 10.6.4

box360: xbox 360 elite

apple airport extreme / fios / 10mb/2mb

retired:

nerdBox: a7n8x-d / xp pro / 2800 athlon xp

quistBox: xbox 1.6b / 250g / xenium ice mod-chip

quistServ: dell pEdge 600sc / 2k3

blackthorne: dell e1505 / mce / 1.83 duo

iQuist: White 3g iPhone / 16g / jailbroken / unlocked TMobile

quistMobile: tmobile mda

quistMobile2: htc g1
dubstar is offline   Reply With Quote
Old May 22nd, 2007 Top | #4

OSNN Folding Team  
Geffy's Avatar
OSNN Veteran Addict
Joined: March 2002
Location: United Kingdom
Posts: 7,805
Reputation: 1490
Power: 213

Default Re: C++: cant resolve string --> string[]

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.


blogtumbloglastfmflickr#rubyonrails@twitter
"I could be replaced with a very small shell script"
Geffy is offline   Reply With Quote
Old May 22nd, 2007 Top | #5
 
X-Istence's Avatar
*
Joined: December 2001
Location: USA
Posts: 6,490
Reputation: 2808
Power: 217

Default Re: C++: cant resolve string --> string[]

I have no clue what you are trying to accomplish, please let me know what you are trying to do.
X-Istence is offline   Reply With Quote
Old May 23rd, 2007 Top | #6
 
dubstar's Avatar
format c:
Joined: December 2002
Location: Southern California
Posts: 1,358
Reputation: 50
Power: 125

Default Re: C++: cant resolve string --> string[]

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.

QuistPro: 13" macbook pro. mid 2009. 10.6.4

box360: xbox 360 elite

apple airport extreme / fios / 10mb/2mb

retired:

nerdBox: a7n8x-d / xp pro / 2800 athlon xp

quistBox: xbox 1.6b / 250g / xenium ice mod-chip

quistServ: dell pEdge 600sc / 2k3

blackthorne: dell e1505 / mce / 1.83 duo

iQuist: White 3g iPhone / 16g / jailbroken / unlocked TMobile

quistMobile: tmobile mda

quistMobile2: htc g1
dubstar is offline   Reply With Quote
Old May 27th, 2007 Top | #7
 
albybum's Avatar
Penguin Rancher
Joined: February 2002
Location: Elizabethton, TN
Posts: 280
Reputation: 180
Power: 125

Default Re: C++: cant resolve string --> string[]

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[]...
albybum is offline   Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules

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