I'm really struggling with being able to do a memcpy but in a special
way... I'm sure maybe there is some other mem... function to achive
this...
I need to copy everything except the few first bytes....
ex:
temp = abd9afd759a76e5d78a6; <- Copy this value only 4 bytes
after ....
//Using some function.... we process temp
print (temp); // afd759a76e5d78a6; <-And I would get this...
Using memcpy(temp2,temp,5); //would only copy "first" 5 bytes...
Hope you understand thanks!
-Jona 9 2943
Jona wrote:
I'm really struggling with being able to do a memcpy but in a special
way... I'm sure maybe there is some other mem... function to achive
this...
I need to copy everything except the few first bytes....
ex:
temp = abd9afd759a76e5d78a6; <- Copy this value only 4 bytes
after ....
What type is temp?
--
Ian Collins.
On May 9, 1:06 am, Jona <medicalsou...@hotmail.comwrote:
I'm really struggling with being able to do a memcpy but in a special
way... I'm sure maybe there is some other mem... function to achive
this...
I need to copy everything except the few first bytes....
ex:
temp = abd9afd759a76e5d78a6; <- Copy this value only 4 bytes
after ....
//Using some function.... we process temp
print (temp); // afd759a76e5d78a6; <-And I would get this...
Using memcpy(temp2,temp,5); //would only copy "first" 5 bytes...
Hope you understand thanks!
-Jona
Look at std::string's assign(...) and substr(...) member functions.
By the way, temp above is nothing at all, it has no type.
Also "abcde" is a literal string but abcde is not.
A much more effective way to ask your question would be something
like:
___
How can i write a function that will return a copy of the literal
string shown below that excludes the first 4 characters?
int main()
{
char* temp = "abd9afd759a76e5d78a6";
}
[hint - the above compiles]
On May 9, 1:50 am, Salt_Peter <pj_h...@yahoo.comwrote:
On May 9, 1:06 am, Jona <medicalsou...@hotmail.comwrote:
I'm really struggling with being able to do a memcpy but in a special
way... I'm sure maybe there is some other mem... function to achive
this...
I need to copy everything except the few first bytes....
ex:
temp = abd9afd759a76e5d78a6; <- Copy this value only 4 bytes
after ....
//Using some function.... we process temp
print (temp); // afd759a76e5d78a6; <-And I would get this...
Using memcpy(temp2,temp,5); //would only copy "first" 5 bytes...
Hope you understand thanks!
-Jona
Look at std::string's assign(...) and substr(...) member functions.
By the way, temp above is nothing at all, it has no type.
Also "abcde" is a literal string but abcde is not.
A much more effective way to ask your question would be something
like:
___
How can i write a function that will return a copy of the literal
string shown below that excludes the first 4 characters?
int main()
{
char* temp = "abd9afd759a76e5d78a6";
}
[hint - the above compiles]
he didn't say "abcde", he said abcde, which probably means 0xabcde
and it seems like "temp" is a sequence of memory.
So in that case, you would get the address of the beginning of temp:
unsigned char * pBegin = &temp;
and you move this pointer 4 "bytes" forward:
pBegin+=4;
and you copy:
memcpy( &temp2, pBegin, a size here );
Should be pretty basic...
Regards,
PQ
On May 9, 7:06 am, Jona <medicalsou...@hotmail.comwrote:
I'm really struggling with being able to do a memcpy but in a special
way... I'm sure maybe there is some other mem... function to achive
this...
I need to copy everything except the few first bytes....
ex:
temp = abd9afd759a76e5d78a6; <- Copy this value only 4 bytes
after ....
//Using some function.... we process temp
print (temp); // afd759a76e5d78a6; <-And I would get this...
Using memcpy(temp2,temp,5); //would only copy "first" 5 bytes...
Hope you understand thanks!
Not really. What is temp?
You can pass any valid address to memcpy, so copying just part
of an array should be no problem. On the other hand, memcpy
only works for very few types; in C++, I'd generally prefer
std::copy (which will work for any type which supports copy).
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
"Jona" <me***********@hotmail.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
I'm really struggling with being able to do a memcpy but in a special
way... I'm sure maybe there is some other mem... function to achive
this...
I need to copy everything except the few first bytes....
ex:
temp = abd9afd759a76e5d78a6; <- Copy this value only 4 bytes
after ....
//Using some function.... we process temp
print (temp); // afd759a76e5d78a6; <-And I would get this...
Using memcpy(temp2,temp,5); //would only copy "first" 5 bytes...
memcpy( temp2 + 4, temp, strlen( temp2 ) - 4 );
>
Hope you understand thanks!
-Jona
Hey guys thanks a lot for you help, I should really made it more
specific. It was a chunk of memory... using a UCHAR type...
the memcpy(temp2+4,temp1,sizeof(temp1) - 4)
did it! ;-)
I apressiate it!
-Jona
On May 9, 2:31 am, pmouse <pmo...@cogeco.cawrote:
On May 9, 1:50 am, Salt_Peter <pj_h...@yahoo.comwrote:
On May 9, 1:06 am, Jona <medicalsou...@hotmail.comwrote:
I'm really struggling with being able to do a memcpy but in a special
way... I'm sure maybe there is some other mem... function to achive
this...
I need to copy everything except the few first bytes....
ex:
temp = abd9afd759a76e5d78a6; <- Copy this value only 4 bytes
after ....
//Using some function.... we process temp
print (temp); // afd759a76e5d78a6; <-And I would get this...
Using memcpy(temp2,temp,5); //would only copy "first" 5 bytes...
Hope you understand thanks!
-Jona
Look at std::string's assign(...) and substr(...) member functions.
By the way, temp above is nothing at all, it has no type.
Also "abcde" is a literal string but abcde is not.
A much more effective way to ask your question would be something
like:
___
How can i write a function that will return a copy of the literal
string shown below that excludes the first 4 characters?
int main()
{
char* temp = "abd9afd759a76e5d78a6";
}
[hint - the above compiles]
he didn't say "abcde", he said abcde, which probably means 0xabcde
and it seems like "temp" is a sequence of memory.
So in that case, you would get the address of the beginning of temp:
unsigned char * pBegin = &temp;
and you move this pointer 4 "bytes" forward:
pBegin+=4;
and you copy:
memcpy( &temp2, pBegin, a size here );
Should be pretty basic...
Regards,
PQ
basic enough to prompt the question:
In your opinion, whats the numeric range of temp's type?
"Salt_Peter" <pj*****@yahoo.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
On May 9, 2:31 am, pmouse <pmo...@cogeco.cawrote:
>On May 9, 1:50 am, Salt_Peter <pj_h...@yahoo.comwrote:
On May 9, 1:06 am, Jona <medicalsou...@hotmail.comwrote:
I'm really struggling with being able to do a memcpy but in a special
way... I'm sure maybe there is some other mem... function to achive
this...
I need to copy everything except the few first bytes....
ex:
temp = abd9afd759a76e5d78a6; <- Copy this value only 4 bytes
after ....
//Using some function.... we process temp
print (temp); // afd759a76e5d78a6; <-And I would get
this...
Using memcpy(temp2,temp,5); //would only copy "first" 5 bytes...
Hope you understand thanks!
-Jona
Look at std::string's assign(...) and substr(...) member functions.
By the way, temp above is nothing at all, it has no type.
Also "abcde" is a literal string but abcde is not.
A much more effective way to ask your question would be something
like:
___
How can i write a function that will return a copy of the literal
string shown below that excludes the first 4 characters?
int main()
{
char* temp = "abd9afd759a76e5d78a6";
}
[hint - the above compiles]
he didn't say "abcde", he said abcde, which probably means 0xabcde and it seems like "temp" is a sequence of memory. So in that case, you would get the address of the beginning of temp: unsigned char * pBegin = &temp; and you move this pointer 4 "bytes" forward: pBegin+=4; and you copy: memcpy( &temp2, pBegin, a size here );
Should be pretty basic...
Regards,
PQ
basic enough to prompt the question:
In your opinion, whats the numeric range of temp's type?
To me he wasn't using "temp" as a varible, just a notation to indicate a
sequence of memory.
Really poor phrased question anyway.
Regards,
PQ
"Jona" <me***********@hotmail.comwrote in message
news:11*********************@p77g2000hsh.googlegro ups.com...
Hey guys thanks a lot for you help, I should really made it more
specific. It was a chunk of memory... using a UCHAR type...
the memcpy(temp2+4,temp1,sizeof(temp1) - 4)
did it! ;-)
I apressiate it!
Incidently, this being a c-style string, if you simply need to print, or
pass to a function, ignoring the first 4 characters you don't really have to
copy into a temp first if you don't want. Using your pseudo code example
of:
print(temp);
you could say
print(temp+4);
Just make darn sure that the length of the c-string temp is greater than 4
:D This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ronny |
last post by:
Can anyone tell me why the following code works fine using an array.
<snip>
double xVal; // array
mxArray *X = NULL; //MatLab mxArrays
|
by: Christopher Benson-Manica |
last post by:
(if this is a FAQ or in K&R2, I didn't find it)
What parameters (if any) may be 0 or NULL? IOW, which of the following
statements are guaranteed to produce well-defined behavior?
char src;...
|
by: Michael B Allen |
last post by:
I just noticed that doing something like the following may fail because
it can overwrite u->size before it's evaluated.
memcpy(u, buf, u->size);
Is it legit that this is a macro as opposed to...
|
by: myhotline |
last post by:
hi all
im very confused about using memcpy and i have three
questions....memcpy takes a pointer to src and a pointer to dest and
copies src to destination...but im very confuzed about when to...
|
by: Martin Jørgensen |
last post by:
Hi,
I'm relatively new with C-programming and even though I've read about
pointers and arrays many times, it's a topic that is a little confusing
to me - at least at this moment:
----
1)...
|
by: Mark |
last post by:
Hi List,
I want to write a function to copy some data out of a hardware buffer.
The hardware can change the contents of this buffer without it being
written to by my function. I want to use...
|
by: 2b|!2b==? |
last post by:
My C appears to be more rusty than I thought, after several years in the
C++ camp. I have a data structure that I want to make a copy of. Here
are the details:
struct MyStructA
{
char barney;...
|
by: Umesh |
last post by:
I want to extract a string abc*xyz from a text file.
* indicates arbitrary no. of characters.
I'm only able to do it when the string has definite no. of characters
or the string length is...
|
by: xdevel |
last post by:
Hi, anyone can make me an example where
memmove does not cause a memory overlapping and
where memcpy do it?
Thanks
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |