QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

std string help!

This is a discussion on std string help! within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; I want to use string in std but I get errors when I do: using namespace std; and when I ...

Reply
 
LinkBack Thread Tools
Old 05-31-2007, 03:08 PM   #1
 
pspballer07's Avatar
 
Join Date: Feb 2007
Posts: 315
Trader Feedback: 0
Default std string help!

I want to use string in std but I get errors when I do:

using namespace std;

and when I try this too:

std::string blah;

How do I use string?

I think its because i am using C and not c++ but how would you do it in C?

Last edited by pspballer07; 05-31-2007 at 03:35 PM..
pspballer07 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-31-2007, 03:37 PM   #2
No longer a community member.
 
a_noob's Avatar
 
Join Date: Sep 2006
Location: Over there.
Posts: 666
Trader Feedback: 0
Default

if you are using namespace of std then why are you calling it as std::string ???

I take it you are wanting to use C++ standard strings.

take a look at this resource C++ Strings
a_noob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-31-2007, 03:43 PM   #3
 
pspballer07's Avatar
 
Join Date: Feb 2007
Posts: 315
Trader Feedback: 0
Default

ok, I changed my code to c++, using namespace std works but now it says 'string' undeclared
pspballer07 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-31-2007, 04:24 PM   #4
No longer a community member.
 
a_noob's Avatar
 
Join Date: Sep 2006
Location: Over there.
Posts: 666
Trader Feedback: 0
Default

Care to post your code?
Hint: #include <string>
a_noob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-31-2007, 04:37 PM   #5
 
pspballer07's Avatar
 
Join Date: Feb 2007
Posts: 315
Trader Feedback: 0
Default

Actually it was <iostream>

I decided to give up with strings because I got it to work but then I had all these undefined reference errors after it compiled.

So my next question is this: Take a look at the code

Code:
void Reader(char str[][])
{
       //do stuff with str
}

int main()
{
     //do stuff
     char data[1][20];
     strcpy(data[0],"Hello");
     Reader(data);
     return 0;
}
ok but I get these errors:
array has incomplete element type

and for the call to Reader() I get the errors:
incompatible types in assignment
type of formal parameter 1 is incomplete


I tried using char** instead but that doesn't work either

help!
pspballer07 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-31-2007, 04:38 PM   #6

It's good to be free...
 
Archaemic's Avatar
 
Join Date: Feb 2007
Posts: 2,440
Trader Feedback: 0
Default

You can't use STL strings or namespaces in C because they were introduced in C++...

And you do need to do #include <string> to use STL string in C++.
__________________
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
Archaemic is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-31-2007, 04:39 PM   #7
 
Maxi_Jac''s Avatar
 
Join Date: Feb 2006
Location: France
Posts: 753
Trader Feedback: 0
Default

You should *learn* C++ .
not trying to discover it this way


++ B
__________________
if I make mistakes in english, feel free to correct me or else i won't progress :D .
Maxi_Jac' is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-31-2007, 04:40 PM   #8
 
pspballer07's Avatar
 
Join Date: Feb 2007
Posts: 315
Trader Feedback: 0
Default

Quote:
Originally Posted by Archaemic
You can't use STL strings or namespaces in C because they were introduced in C++...

And you do need to do #include <string> to use STL string in C++.
ok but look at the post right before yours, I have a question
-= Double Post =-
OK, after a ton of trial and error, I solved my problem
I ended up using char *data[] instead of char data[][]

Last edited by pspballer07; 05-31-2007 at 05:03 PM.. Reason: Automerged Doublepost
pspballer07 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-31-2007, 10:01 PM   #9

Heroes never die
 
hallo007's Avatar
 
Join Date: Aug 2006
Location: ...........
Posts: 1,318
Trader Feedback: 0
Default

we have a c/c++ help thread , ask your questions there just like everbody does
hallo007 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-01-2007, 02:28 AM   #10

Developer
 
yaustar's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,317
Trader Feedback: 0
Default

The undefined errors are from NOT linking the C++ STL library. Look in the C/C++ help thread to see how.
yaustar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-01-2007, 08:30 AM   #11
 
pspballer07's Avatar
 
Join Date: Feb 2007
Posts: 315
Trader Feedback: 0
Default

Quote:
Originally Posted by hallo007
we have a c/c++ help thread , ask your questions there just like everbody does
sorry
pspballer07 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-01-2007, 03:30 PM   #12
No longer a community member.
 
a_noob's Avatar
 
Join Date: Sep 2006
Location: Over there.
Posts: 666
Trader Feedback: 0
Default

As for your code try just passing Reader(char *str) A pointer will work for any type of array you have. And then call it like so Reader(&data);
a_noob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
std , string

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 02:43 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us