Questions tagged [memmove]

memmove() is a C standard library function to copy a block of memory. It work even if the source and the destination overlap.

144 questions
0
votes
0 answers

Removing a char at index i in a string and make new strings C

Suppose we have a string called StringA[] = "ABCD". you have to delete only one char and make new strings like "BCD, ACD,ABD,ABC". is this case you need to determine how many time the strings appears in a other string StringB[]; the length of…
Payam30
  • 689
  • 1
  • 5
  • 20
0
votes
0 answers

What are the possibilities to move objects in memory?

Trivially copyable objects can be moved in memory by memmove, such as: struct X { }; int main() { static_assert(std::is_trivially_copyable_v); X* px1 = (X*)operator new(sizeof(X)); new(px1) X{}; X* px2 = (X*)operator…
Daniel Langr
  • 22,196
  • 3
  • 50
  • 93
0
votes
1 answer

Python - ctypes.c_char.from_buffer vs ctypes.c_void_p(string)

What would be the difference between: pointer = ctypes.c_char_p('abc') and string = 'abc' buffer = (ctypes.c_char * len(string)).from_buffer(string) Technically both are pointers when passed in their respective function calls like such: (cross…
0x5929
  • 400
  • 1
  • 4
  • 16
0
votes
1 answer

Why does memmove behave different when i want to replace a string at the first letter?

In the Code below, i don't understand, why i have to write memmove like this in the if statement when pos == 0 (when i want to replace at the first position of the string array) : strlen(string1) - strlen(string2+1)) I think i don't understand how…
Sedem
  • 47
  • 1
  • 9
0
votes
2 answers

Finding time taken by the code

I am trying to find the time taken by memmove function in c using time.h library. However, When i execute the code, I get the value as zero. Any possible solution to find the time taken by the memmove function? void main(){ uint64_t…
0
votes
1 answer

Adding new line terminator to the end of every line

What is the best way to add a '\r' to my new-line sequence? I am writing a string to a file and doing various parsing to it but according to my assignment spec a new line will be considered '\r\n'. Right now I only have a new line at the end. I was…
0
votes
2 answers

Performance of memmove compared to memcpy twice?

I have seen the difference pointed in the accepted answer in What is the difference between memmove and memcpy? and it said memmove might be very slightly slower than memcpy. We can implement an alternative for memmove by doing as follows: allocate…
duong_dajgja
  • 4,196
  • 1
  • 38
  • 65
0
votes
1 answer

C++ - How to use memmove for items in 2D array?

I have the following 2D array: float accumulator[MAX_CHANNELS][2*MAX_FRAME_LENGTH]; and I keep moving the blocks of memory in my code for every channel like this: for (int channel = 0; channel < nChannels; channel++) { …
ivana
  • 1
0
votes
1 answer

Will memmove function share the same address as the temporary pointer?

Suppose there is pointer to an array of float values: float *source; and we know its size as int sourcesize; There is an already implemented function which add an element to the souce array from the inputVec: void addRecord(const float* inputVec,…
lightrek
  • 951
  • 3
  • 14
  • 30
0
votes
2 answers

Markov chain. Implementation add method

I am a bit confused with the next statment in implementation: void add(char *prefix[NPREF], char *suffix) { State *sp; sp = lookup(prefix, 1); //addsuffix(sp, suffix); printf("size of prefix %d",&prefix); printf("size of prefix…
0
votes
2 answers

Memmove() in C prints the result twice

I was playing around with memmove and I understand how it works. But whenever the end result contains more than the original source size, it prints out a bunch of random numbers. For example: char str[] = "abcdefgh"; memmove(str + 6, str + 3,…
MushSD
  • 9
  • 1
0
votes
1 answer

memcpy or memmove between different arrays

I was reading some information about memcpy and memmove, and if I'm not wrong, you can use both for move memory between different arrays. So here is my question: If I want to concatenate this objects with this method. class List { // Pointer to…
Soutuyo
  • 106
  • 10
0
votes
1 answer

Apply memmove function to a 3d array

I am trying to achieve the fftshift function (from MATLAB) in c++ with for loop and it's really time-consuming. here is my code: const int a = 3; const int b = 4; const int c = 5; int i, j, k; int aa = a / 2; int bb = b / 2; …
0
votes
1 answer

Removing characters from an input string in c

My objective is to remove user defined amount of characters from a string in C. The code requires the user to input a string, indicate the start of the characters they want removed and indicate how many characters from that position they want…
0
votes
2 answers

memcpy issue -> trying to copy an array of struct

I am completely lost on why memcpy or memmove is not working for me. I am trying to copy a array of struct (joblist) to another array of same struct (Q) to use for data manipulation, while keeping my original array intact. I have spent a lot of time…
subcan
  • 2,021
  • 2
  • 18
  • 21