main_loop: ; edx contains first dword of sorc string
mov [edi],edx ; store one more dword (I GET THE ERROR IN THIS LINE)
add edi,4 ; kick dest pointer
main_loop_entrance:
Any help?
Or... could you show me your strcat.asm to see if, by mistake, something was changed...?
Thanks
strcat stopped working...
Hi,
For some time now, I haven''t been able to use strcat, and when I debug the error, I get an ''Object reference not set to an instance of an object.'', inside strcat.asm:
That code from strcat.asm is correct. I suspect it''s not strcat''s problem, but a mistake in how you''re calling it or what you''re passing to it. Post some of that code instead.
I''m sure something happened but it is neither from my code nor from strcat.asm, if you say so, because I had this program compiled a week ago using strcat, I recompiled it again yesterday without changing a thing and using the same compiler, and I get the error... its weird!
make a new empty project with just a strcat call, nothing else. see if that works. then you will know if its your problem or not.
still get the same error... and made the simplest program possible:
AHHHRRRGGHHH!
char *path = "Hello";cout << path << endl;strcat(path, ", World");cout << path << endl;
AHHHRRRGGHHH!
Your "path" variable is just a pointer. By pointing it to "Hello", you're pointing it to memory that the compiler sets up as 6 bytes ("hello" plus a nul char) and who knows what the compiler put in memory after the "Hello". By strcatting to it, you're basically overwritting that memory, hammering memory you don't own, and thus bad things happen.
Change
char *path = "Hello";
to
char path[100] = "Hello";
or
char *path;
path = new char [100];
strcpy(path, "Hello");
// don't forget to delete [] path; after you're totally done with path
Try that. Should work.
[edited by - BriTeg on March 27, 2004 2:32:55 PM]
Change
char *path = "Hello";
to
char path[100] = "Hello";
or
char *path;
path = new char [100];
strcpy(path, "Hello");
// don't forget to delete [] path; after you're totally done with path
Try that. Should work.
[edited by - BriTeg on March 27, 2004 2:32:55 PM]
I''d recommend you drop the C style strings altogether and use the string template class in the STL. This wouldn''t have even been a problem then.
the char * abc = "abcd" ...
...is implicity constant, it is identical "const char * abc....".
...is implicity constant, it is identical "const char * abc....".
Or of course you could do:
You have to create a variable array large enough to fit the strings + a NULL. You then have to copy the first section into the new array and THEN append the second section within that new array. As was said before, "something" is a constant value in your program, not allocated at run time.
And Mastaba: You don''t learn anything about how strings work if you use std::string. True, it works, but if you use it without having worked on it yourself, you''ve robbed yourself of some programming experiance. That''s MY opinion at least, you''re free to feel and say that using std::string is better.
char* hello = "Hello";char* world = ", World";char* printout = new char[strlen(hello) + strlen(world) + 1];strcpy(printout, hello);strcat(printout, world);cout << printout << endl;//As BriTag said, remember delete[]printout. //You should NOT delete hello or world.
You have to create a variable array large enough to fit the strings + a NULL. You then have to copy the first section into the new array and THEN append the second section within that new array. As was said before, "something" is a constant value in your program, not allocated at run time.
And Mastaba: You don''t learn anything about how strings work if you use std::string. True, it works, but if you use it without having worked on it yourself, you''ve robbed yourself of some programming experiance. That''s MY opinion at least, you''re free to feel and say that using std::string is better.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement