Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

RanBlade

string creation

This topic is 5616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok iam making a simple hamgman game in a win32 API. but what iam trying to do right now is make some kind of loop that will make a string of "X"''s in the same length of the string that the word chosen for the game to display in the box that shows the encrypted word. any help would be great. thanks

Share this post


Link to post
Share on other sites
Advertisement
ok a lil revision on that...

I need to make a loop that will take lets say the game chose "online" as the word for the game and use its length of 6 to created a string of "X"''s in the length of 6 to act as a encrypted word....

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you use C++:

string str(3, ''X'');

creates a string of 3 X.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
So what''s the problem with the solutions above?

Share this post


Link to post
Share on other sites
Ok iam dumb. But in my test function when i set this up it compiles just fine... this is a console app to test my fucntions as i create them... but the code goes as follows


char* pszString;
pszString = Word();

//using namespace std;string word( "RanBlade" );string x( word.size(), ''X'' );

using namespace std;

string word1(pszString);
string x(word1.size(), ''X'');

now when i try to include that into my Win32 API i get a lot of errors... if you need anymore code segments just tell me thanks..

Share this post


Link to post
Share on other sites
well first, comment out the code you posted, and just try an int main(void) function with the new Win32 API stuff you are using ... which will tell you once and for all if the errors are in your string code, or your Win32 code ... cause I''m guessing it isn''t the string code ... and BTW ..always post at least the first error message when you say you have errors, cause many of us might know the exact error cause if you did

Share this post


Link to post
Share on other sites
sorry for my ignorance.. lol iam new to C++ Windows programming. but here are the error msgs in my win32APP

:\Source Code\hangmangame\gamewindow.cpp(31) : error C2872: ''string'' : ambiguous symbol
C:\Source Code\hangmangame\gamewindow.cpp(31) : error C2872: ''string'' : ambiguous symbol
C:\Source Code\hangmangame\gamewindow.cpp(31) : error C2146: syntax error : missing '';'' before identifier ''word1''
C:\Source Code\hangmangame\gamewindow.cpp(31) : error C2065: ''word1'' : undeclared identifier
C:\Source Code\hangmangame\gamewindow.cpp(32) : error C2872: ''string'' : ambiguous symbol
C:\Source Code\hangmangame\gamewindow.cpp(32) : error C2872: ''string'' : ambiguous symbol
C:\Source Code\hangmangame\gamewindow.cpp(32) : error C2146: syntax error : missing '';'' before identifier ''x''
C:\Source Code\hangmangame\gamewindow.cpp(32) : error C2065: ''x'' : undeclared identifier
C:\Source Code\hangmangame\gamewindow.cpp(32) : error C2228: left of ''.size'' must have class/struct/union type
C:\Source Code\hangmangame\gamewindow.cpp(36) : error C2872: ''string'' : ambiguous symbol
Error executing cl.exe

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!