|
I was trying to write the string object and ran into trouble. I'm getting run-time error. The run time error says: blah blah... the memory could not be "read".
I'm using MinGW g++ to compile this program. The program is actually much much longer but i deleted everything that used to be there so it is easier to figure it out.
The run-time error occurs inside of the c_str() function.
But it happens before leaving the substr() function (which calls the c_str() function)
The c_str() function works without generating runtime errors sometimes.
here is the output of my program:
in c_str(): string=this, was, a, test
before new char[18]
after new char[18]
after data is copied.
out c_str()
from main(): this, was, a, test
in substr:
new char[8]
after new char[8]
leaving substr
in c_str(): string=this, wa
before new char[8]
after new char[
and then the runtime error occurs.
So, basically, I get runtime error on the line of code that says:
tmpStr = new char[size]; (inside of c_str()), but why would new char[8] cause a runtime error?
It makes no sense to me everything looks correct to me its driving me insane.
Please help.
|
|
|
|
|
I think i screwed up and posted this message in the wrong section of this website. Maybe it should be under: ATL / WTL / STL
I know people really get upset when users like me do this, but now its too late. I appologize for the mistake.
|
|
|
|
|
I am taking C++ and does anybody know how to make a password code to read a encrypted password simple and easy.
Any suggestions would be helpful.
|
|
|
|
|
where do you hope to read it from ? Do you want to decrypt it, encrypt it, or both ? As you're asking in the managed C++ forum, the .NET framework provides a namespace full of cryptography APIs. As it seems you're 'taking C++', I assume you've asked in the wrong area, and your question relates to ANSI C++. If you could perhaps clarify where you want this password to come from and go to, and what you want to happen to it along the way, perhaps I can help you further.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
This may seem easy, but I swear I cannot find a simple answer.
I have a directory which I plan to make readable by all, but writtable only by Admin group. I need, whne I create files, with code, protect those files from being written by any except Admin. I would also like to make it readable by only Admin and an Operators group if possible.
Can someone give me a clue on what classes to use, and / or a pointer to a web site with an example.
TIA
|
|
|
|
|
I'm looking for a way to send a formated string to the printer using mc++. I have looked into MFC and it seems pretty in depth. Any advise would be greatly appreciated.
Thanks
|
|
|
|
|
MFC printing is easy. There are a couple of helper classes on this site, but just adding support with the wizard gives you the methods you need, you end up printing in your main onpaint method, from memory, and some other methods just set up the printer for you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How to Print a file By a program Using C++ Ver. Borland 5.2.
Please Send me a Function that prints a given file object.
Thank You.
Dohan
|
|
|
|
|
to print it in a file
void func()
{
// given object(file1)
fstream file1("pass.dat",ios::app|ios::binary|ios::in|ios::out);
file1.write((char*)&x,sizeof(x));
//x is an object
file1.close();
}
to output a file object
void func()
{
fstream file1("pass.dat",ios::app|ios::binary|Ios::in|ios::out);
file1.seekg(0);
file1.read((char*)&x,sizeof (x));
}
ushani
|
|
|
|
|
Hi Guys I have been banging my head against the wall for some time.Please Help...
I have downloaded an example in C#.NET and have made some conversion that have worked
in my C++.NET winform application. Does anyone have any ideas?
The last line does not work.......
// get the collection of sheets in the workbook
//C# example
// Excel.Sheets sheets = theWorkbook.Worksheets;
// This conversion works
Interop::Excel::Sheets *sheets = theWorkbook->Worksheets;
//C# example
// Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
// This does not work..it is looking for a
// error C2664: 'Interop::Excel::Sheets::get_Item' : cannot convert parameter 1 from 'int'
// to 'System::Object __gc *'
Interop::Excel::Worksheet *worksheet = (Interop::Excel::Worksheet*)sheets->get_Item(1);
|
|
|
|
|
Does anybody know how to call an executable from a C++ program
|
|
|
|
|
I think you call a method on the Process object.
|
|
|
|
|
I have 2 forms. The parent form has some text boxes that the child form populates. The child form pop up when the user chooses to enter information. how can i get the user input from the second form to the parent form? I tried setting the variable as public but it did not seem to help. Any suggestions? Thanks
|
|
|
|
|
Lagwagon56 wrote:
I tried setting the variable as public but it did not seem to help. Any suggestions?
I'd guess you set the text boxes to be public ? This is a bad idea for a number of reasons to do with good design, but the core issue is that once your form is closed, those text boxes no longer exist. You need to override the OnClose method, so that before the form closes, the text you want to retrieve is copied to some string variables, and then expose some get methods to return those strings after the form is closed.
BTW, this is the managed C++ forum, a question like this is better in the C++ forum, even if you use MC++ ( because it's not related to managed extensions ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus,
Thanks for the reply. I figured out a way to pass variables by creating a class that passes the information. I just pointed each from to it. Thanks again.
|
|
|
|
|
we need to control a web cam to take a poto in a speipic time
|
|
|
|
|
Ok,
Not C#,
Not VB,
Not using DirectX.
Using Visual C++ .net managed code, I havent found a way to play waves as
in the old Win API call PlaySound().
All the uses of importing winmm.dll such as:
[DllImport("winmm.dll")]
public static extern bool sndPlaySound(byte[] pbyte, int param);
are for VB or C#.
Any help in figuring this out would be greatly appreciated!
Scott
Old Windows App builder.
|
|
|
|
|
This might be TOO easy for you, but,...
The DirectX 9 SDK (Summer Edition, and I suppose the latest download), has a Managed Version of the DirectX 9 DLLs. You can view the contents of the assemblies in the IL Disassembler; which makes for almost effortless usage. Just reference the assembly with the #using directive and set the correct search path for the Visual C++ .NET include and reference files directories, and your Intellisense should show you everything.
But, if you actually WANT to do it the hard way,...
|
|
|
|
|
Thats not a dumb suggestion ursus I hadnt thought of those new DLLs... didnt think MS
would go to all that trouble when they were planning on changing the managed code and
C++ anyway.
I'll give it a try.
And as an aside, the easy way is my ALWAYS my favorite way! Especially when dealing with MS
compilers hehe.
Thanks again...
Scott
|
|
|
|
|
|
I keep trying...
So after downloading and installing the latest version of DirectX SDK
with the included Managed Code additions and trying to link in the
Microsoft.DirectX.dll so that I can do as you suggested:
using namespace Microsoft::DirectX;
no amount of letting VS.Net know by way of "Additional Include Directories" can i get
it to recognize the namespace.
All I get so far is...
Microsoft::CSharp, Microsoft::VisualBasic, Microsoft::Win32.
I guess I'm mired in the old "Hard" ways of doing things I just dont understand.
Any help would be greatly appreciated.
Scott
|
|
|
|
|
I should have gone into greater detail (because I made the same mistake).
If you have your solution open in Visual C++ .NET, right click on the Project (which is just below the solution in the Solution Explorer). This will open the Dialog Box for setting search directories. You want to open the Property page and set the search path that Visual Studio uses to find include headers, LIB files, and .NET assemblies. Open the Projects folder. Select VC Project Directories and then select the List Box option (It's in the upper right corner) for Reference Files (the default is for the include files). There will be a text message displayed explaining that Reference Files are those that you include in your source code with the #using directive (these have DLL extensions). Then when the text box appears, you type in the path to the installed directory (on my Computer, it's: "C:\WINDOWS\Microsoft.NET\DirectX"). Or, use the Browse button.
You'll know when you've gotten it, because suddenly your Intellisense will be displaying your DirectX stuff.
If all that fails, you can, of course, copy the DirectX 9 Managed DLL and paste it into the current directory in which your Solution file resides.
Here's the MSDN info:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxurfVCDirectoriesProjectsOptionsDialogBox.asp[^]
|
|
|
|
|
I have an application in MFC that I have added some ADO.NET code to.
My DatabaseAccess class is unmanaged and has pointers to OleDbConnection which is used in the class member functions to manipulate the database.
I also have an unmanaged CFormView class that includes the DatabaseAccess class as a member.
I declared a pointer to the CFormView class so that other places in the code have access. CFormView * theDialog;
When I call the member functions in the DatabaseAccess classs, the OleDbConnection is checked for NULL to make sure the connection is there. All calls to the DatabaseAccess member functions work from the CFormView class.
When in CMainFrame on a timer I call theDialog->UpdateRecord() which in turn calls an OpenDatabase member of my DataAccess class, the check if(m_OleDb_connection != 0) causes an NullReferenceException to be thrown and the debugger shows that no instance of the connection has been assigned to the variable holding the OleDbConnection.
I thought this might have something to do with pinning or Threads. Any suggestions?
|
|
|
|
|
Sorry, just a bad pointer. theDialog was not set properly and was a bad reference.
|
|
|
|
|
In manged c++ code, I created several objects, and added them into a arraylist. Then I called a managed function and passed the arraylist as a parameter. In the c# side, I used the objects in the arraylist to invoke several events. I suppose that the garbage collector of c# would release the objects when they are done. But there is always memory leak somehow. Could anyone tell me why?
Thanx
|
|
|
|