string creation
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
#include <string>using namespace std;string word( "RanBlade" );string x( word.size(), ''X'' );
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
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....
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....
Some possibly useful functions :
string::find
string::find_first_of -
string::find_first_not_of
Look them up.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
string::find
string::find_first_of -
string::find_first_not_of
Look them up.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
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..
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..
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
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
:\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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement