|
I know with regular arrays you would do a sizeof(mystring)/sizeof(string), but I really don't know about with string variable types.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Cool,
What about if we take it one step further and have this:
int main()
{
string mystring[] = {"ASD","asdf"};
int i;
i = myfunc(mystring[]);
cout << i;
return 1;
}
int myfunc(string mystring[])
{
int i;
i = sizeof(mystring) / sizeof(mystring[0];
return i;
}
I get two different results when using the sizeof() in myfunc and sizeof in main....
Do I need to pass a pointer to the string??
|
|
|
|
|
You must pass the array size to myfunc. Myfunc receives a string pointer (that's all an array really is, a pointer to a contiguous block of strings), and has no way of knowing the size of the array that pointer points to.
Inside the main function, the compiler substitutes the sizeof operator for the actual known size of your string array. However, inside the myfunc function, the compiler has no way to determine the size of the array passed. If you print the sizeof(mystring) in myfunc, you'll find it always equals 4, the size in bytes of a pointer (on the x86 architecture).
It would probably be better if sizeof() never worked on arrays at all. At least then it would be consistent and less likely to confuse people who've never run into this before.
|
|
|
|
|
It might be preferable to find a way to use
vector< string > mystring ;
Then mystring.size () is obviously the size...
Otherwise you could use a sentinel,
<br />
string mystring [] = { "Hello", "World", "" } ;<br />
<br />
void DoSomething ( string mystring [])<br />
{<br />
while ( !mystring->empty ())<br />
{<br />
DoSomethingWithMystring ( mystring ) ;<br />
++mystring ;<br />
}<br />
}<br />
Paul
|
|
|
|
|
I've finally made my DLL (with help that I am truly grateful for from many members of CodeProject - thanks for being patient ) .However I actually made the DLL to be called from Delphi instead of VB. I have been using VB because I know VB. But the function in the DLL accepts strings, which for VB I have used BSTR and __stdcall. Can I still use BSTR for Delphi and what about the calling convention? Thanks in advance for all your help!!!
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Just google it.
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
If your DLL api's input is a BSTR then the code in delphi has to pass the parameters in BSTR.
otherwize it will simple not work.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
I am facing a head scratching problem in building a Win32 Dll. I have some C++ classes in the Dll and I want to access these classes in a C++ client. These classes contain some static data and also Dll has some global data. I have successfully build the DLL, but when I use this DLL in client, I get Linker error "LNK2001: unresolved external symbol" for static as well as global data.
I viewed the exports of dll with dumpbin utility and dumpbin shows this data exported but linker is not finding it in the dll. I read somewhere that there is a SECTION statement in .DEF file which deals with the defualt scope of global and static data in a DLL. Can this be used to rectify this problem and if yes then how? As a note, I am not using .DEF file to build the dll, I am using __declspec(dllexport) keyword to export classes and global data from dll.
Please help me, I am scratching my head at the moment.
|
|
|
|
|
You sound like you're a lot smarter than me, so please forgive me if I sound stupid. But I was just wondering if you're actually #include-ing the header file and linking to the .lib file. Or don't you have to do this? Please don't think I'm being sarcastic, but I've just gone through a DLL hell of my own and I'm still kinda new, so I'd also like to know the answer;)
If it's broken, I probably did it
bdiamond
|
|
|
|
|
yes, I m including the header file and also linking with .lib file but ...........................
|
|
|
|
|
sorry, that's about the extent of my knowledge. Wish I could've been more help
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Hi there.
I am facing an issue. I am not able to invoke MS Outlook Exp. from my VC++ application. What I need is, when I click on a button, Outlook exp. should came up with an E-Mail address that we are getting from our own database.
Thanks and Regards,
Pankaj Bhalla
pankajbhalla@mantraonline.com
|
|
|
|
|
what do I have to search for to be able to fix large font/small fonts problems ?
The problem is that the dialog size is fixed ( which is not supposed to be, I think ) so now, in large font, some controls overlap; and I need to resize.
Is MapDialogRect the way to go ?
Is there a way to debug large font/small font without having 2 computers or need to restart each time I change the setting ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
If you do your work in Large Font mode things will work out.
Todd Smith
|
|
|
|
|
i created new mfc application with multi doc/view. now, i would like to have also treeview in the main dialog. i would put it on the left of it. how to do that?
any ideas?
|
|
|
|
|
I dont have the exact idea... what all changes are to be made, but just for a help you can construct a new doc/view project with splitter window and checkout the OnCreate event of the frame thats where the splitters are created.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Option 1
Follow the excellent instructions from "Paul R Thompson"
Pauls Splitter Gear
Download and copy
MFC SplitterWnd Sample
Option 2
Copy this.
[1] Create new project (sdi)
Add this to MainFrm.h
CSplitterWnd split;
BOOL m_bInitSplit;
Initialise m_bInitSplit to FALSE in MainFrm.h constructor.
Override OnCreateClient in CMainFrame (alt+enter in VC 6.0 mode or ctrl-alt-x-click in BS .NET mode)
Add this
CRect cr;
GetClientRect( &cr);
if ( !split.CreateStatic( this,1,2) )
{
MessageBox( "Error setting up splitter frames!",
"Init Error!", MB_OK | MB_ICONERROR );
return FALSE;
}
/* Note CTreeStuff is not defined yet. See later */
if ( !split.CreateView( 0, 0,
RUNTIME_CLASS(CTreeStuff),
CSize(200,50), pContext ) )
{
MessageBox( "Error setting up splitter frames!",
"Init Error!", MB_OK | MB_ICONERROR );
return FALSE;
}
/* you will have to change this to your RUNTIME_CLAS CView derived class */
if ( !split.CreateView( 0, 1,
RUNTIME_CLASS(CtmpView),
CSize(cr.Width(),cr.Height()), pContext ) )
{
MessageBox( "Error setting up splitter frames!",
"Init Error!", MB_OK | MB_ICONERROR );
return FALSE;
}
m_bInitSplit = TRUE;
ensure that you replace
return CFrameWnd::OnCreateClient(lpcs, pContext);
with this
return TRUE;
Add a MFC class CTreeStuff deriving from CFormView
Drag a CTreeCtrl and plonk it your form view.
Add stuff to your tree control.
Regards,
axe
|
|
|
|
|
Solution is good, but really this wont go to the inbox of the original poster.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
|
lordgreg is the person who needs the help... so when you reply to me he will not be notified about the solution that you have posted. Thats what i meant to say.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Check back on code project for answer to your question.
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&df=100&app=50&fr=101
|
|
|
|
|
Hi Everyone,
I am looking for a SDK or a developer's tool that will allow me to write a program that will allow the user to visually edit an EMF file. In other words, I would like my program to let the user select different components of an EMF file and move or modify them.
Does anyone know of a SDK (C++ bases preferred) commercial or shareware, that could assist me in this project?
Any help is greatly appreciated.
Thanks,
A.
|
|
|
|
|
|
Thank you for the suggestion but this SDK looks to be a conversion tool rather than an editing/manipulation tool, which is what I really need. Once again thank you for the help and please keep me posted if you think of other sites.
A.
|
|
|
|
|