|
I think I understand.
Did my supposed solution seem capable or am I still not understanding things clearly?
Might someone be able to give me an example of how I should write the assignment for magiitr?
Thank you.
|
|
|
|
|
I can't see any of the "<" or ">" characters on what's between in your code.
Steve
|
|
|
|
|
Kataric wrote: If an iterator is not a pointer, then what is it?
It is a generalization of a pointer that allows you to work with different data structures in a uniform manner.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I think the vector operator[] returns a reference to the element at that index, not an iterator.
So you'd want:
player::Magi& magi = Player1.Magi[mage1];
or
player::Magi* pMagi = &Player1.Magi[mage1];
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I must seriously be confused here.
Like Mr. Echols is saying, I could declare a new instance of the player::Magi class and set Player1.Magi[mage1] equivalent.
However, I won't be able have any ->next functionality that comes with the vector iterator, and that's really what I'm after.
I'll also go back and look up references on the vector class.
I shall post more stuff in detail tomorrow in hopes that you can help me figure this out.
|
|
|
|
|
Hey Gentlemen, I contemplated opening a new thread for this question, but hopefully this one will do.
I think I understand what is going on with the darn pointers and interators and how I used them. Unfortunately I'll need to rewrite a lot of things.
However, I'm having another problem with another compiler error.
c:\nehe\magi\magination\spelllist.cpp(1275) : error C2228: left of '.current_energy' must have class/struct/union
The code is question is
caster.Creatures[i].current_energy = nrg[i];
I'm not sure what this "must have class/struct/union means.
Any help would be much appreciated.
|
|
|
|
|
This is typically the cause of that error (at least for me):
CMyObject* pObj = new CMyObject();
pObj.DoSomething();
Try changing it to:
caster.Creatures[i]->current_energy = nrg[i];
and see if that works.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Is there any fuction that compare 2 strs
str1 = "BMW"
str2 = "BmW"
and that fuction would return TRUE (or something else) while comparing these 2 strs?
or should i create that fuction ?
|
|
|
|
|
What are str1 and str2 ? char arrays ? std::strings ? CStrings ? bstr_t ?
Most string classes offer operator ==. Two char * can be compared with strcmp, from memory.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
I just want to return me true below :
CString str = "BMW";
CString str2 = "BmW";
CString str3 = "bMW";
if ( str == str2 && str2 ==str3) etc
|
|
|
|
|
use CompareNoCase function of CString..
|
|
|
|
|
Well i am facking idiot :/ it was inside my eyes and i did a whole post :/
|
|
|
|
|
hm i found MakeUpper for CStrings
so i will make them MakeUpper before i put them in if ( ) {}
right?
|
|
|
|
|
if (0 == str1.CompareNoCase(str2))
{
//strings are equal, ignoring case
}
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
thx about that too (i will use this and not that i said about MakeUpper)
|
|
|
|
|
The old-skool strxxx functions have versions that ignore case - e.g. stricmp()
The i is for ignore!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi all. Im trying to find a reasonable explanation on how to call the ExitThread() function properly. Would i need to call it for every thread i call?
ie:
<br />
<br />
CreateThread(somethread);<br />
CreateThread(somethread);<br />
WaitForMultipleObjects(somethread);<br />
<br />
ExitThread(somethread);
Thanx in advance!
|
|
|
|
|
dellthinker wrote: Would i need to call it for every thread i call?
No. your thread will automatically end when you return from the thread function.
|
|
|
|
|
ExitThread exits the current thread, not some arbitrary thread identified by a HANDLE . The argument is an exit code not a HANDLE .
Steve
|
|
|
|
|
Hello everybody,
lets say i have small 640bytes executable with a code like this:
#include "windows.h"<br />
<br />
int WinMainCRTStartup()<br />
{<br />
MessageBox(0,"AAA","BBB",0<br />
return 0;<br />
}
.rdata and .text sections are merged so there is only one .text section in that *.exe
so what i need to do to add new section manualy, with hexeditor?
i know that i have to add new Image Section header which is 28 bytes lenght and new section at the end of file which is random lenght described in its section header.
I also have to correct each section pointer(in my case just one section) so if i add additional 28 bytes in front of sections i have to add 28byte to each section pointer so in my case offset will be 200+28, but my hexeditor shows that ofset to the section begining is 208, so i will better trust my hexeditor. And finaly i changed sections count to 2 so.. chages were made executable saved but it doesn't work.
what i have missed?
thank you for help in advance
|
|
|
|
|
This should get you started:
#include "stdafx.h"
#pragma data_seg(".MySeg")
int g_ImInAnotherSegment = 0;
#pragma data_seg()
#pragma comment(linker, "/SECTION:.MySeg,RW")// Make section readable and writable.
int main(int argc, char* argv[])
{
return 0;
}
Steve
|
|
|
|
|
my application currently reads and uses data from files at a location on the host machine using fstream
what i would like to do is include these files and their data as resources so that the application does not rely on the data being stored on the host machine
i am using FindResource, LoadResource, LockResource etc but i'm having trouble passing the actual data content straight to fstream - is this possible??
<br />
FindResource(..);<br />
LoadResource(..);<br />
char* ptr = (char*) LockResource(..);<br />
<br />
fstream.open(ptr,ofstream::binary);<br />
any help would be greatly appreciated - i'm pretty new to resources!
|
|
|
|
|
bimgot wrote: char* ptr = (char*) LockResource(..);
What do you want to do with ptr at this point?
bimgot wrote: fstream.open(ptr,ofstream::binary);
The first argument to fstream 's constructor is the name of the file to open, not the actual data within the file. Perhaps that is where your confusion lies.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
as i understand LockResource returns a pointer to the first byte of the data stored in the resource.. currently i use fstream to read, validate and store some wave file data so that it can be used to play back the wave file
since the open function of fstream takes a char* for the name of the file to open, i wondered if a char* for the resource would work in the same way
i think my confusion is as you say with fstream but since the class i want to use the data from the resource with is based on fstream, i wondered if there was a solution that doesnt involve re-writing the class..
|
|
|
|