I am trying to put the contents of a char buffer[512] into a word* (type def as data type short). How do I do this? I have tried memcpy but am either getting an exception or it will run but the word* is undefined value after the copy. Any advice would be appreciated. Thanks.
Nemoticchigga
0
Junior Poster in Training
Recommended Answers
Jump to Postpost code, such here is how it might be done
char buffer[512] = "Hello World"; // allocate memory for the new string char* ptr = new char[strlen(buffer)+1]; // now copy strcpy(ptr, buffer);
Jump to PostI always hate it when someone changes a descriptive name like short, which is a small integer, to something like word, which to me should be a string of some sort rather than an alias for short. That being said, if you are truly trying to change a string, like …
All 5 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
Nemoticchigga
0
Junior Poster in Training
Lerner
582
Nearly a Posting Maven
Ancient Dragon
commented:
yes, its very confusing when people do that.
+34
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.