So i ran the below code on codeblocks and it showed 11234 with both memmove() while the second one should be 12344.I ran the programme on gcc on linux terminal and it showed 12344 for the second memmove() which is correct. The compiler i am using for codeblocks is gcc which i ran on the linux terminal and it gave the correct output.So don't know what is the problem here.
OUTPUT:- https://imgur.com/a/vy8EdL7 (https://imgur.com/a/vy8EdL7)
CODE:-
#include<stdio.h>
#include<string.h>
int main()
{
char array[5]={1,2,3,4,5};
memmove(&array[1],&array[0],4);
for(int i=0;i<5;i++)
{
printf("%d",array[i]);
}
printf("\n");
memmove(&array[0],&array[1],4);
for(int i=0;i<5;i++)
{
printf("%d",array[i]);
}
printf("\n");
}
BUILD LOG
-------------- Clean: Release in test (compiler: GNU GCC Compiler)---------------
Cleaned "test - Release"
-------------- Build: Release in test (compiler: GNU GCC Compiler)---------------
gcc -Wall -O2 -Wfatal-errors -Wextra -Wall -std=c11 -c /home/titan/Desktop/C_source/test/main.c -o obj/Release/main.o
g++ -o bin/Release/test obj/Release/main.o -s
Output file is bin/Release/test with size 14.03 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
VERSION INFO:- CODEBLOCKS:- Release 17.12 rev 11256 Sep 3 2018, 07:29:05 - wx3.0.4 (Linux, unicode) - 64 bit
GCC:-gcc (GCC) 8.2.1 20180831
LINUX:-4.18.9-arch1-1-ARCH