Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C Compiler.
- Code, Compile, Run and Debug C program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <stdio.h>
- long * move_to_function(long *arr, long nelements) {
- long newArr[nelements];
- newArr[0] = arr[nelements-1];
- int i;
- for (i=0; i<nelements; i++) {
- newArr[i + 1] = arr[i];
- };
- long* arrb = &newArr;
- return arrb;
- }
- void printarr(long *arr, long nelements){
- int i;
- for (i=0; i<nelements; i++) {
- printf("%ld ", arr[i]);
- }
- printf("\n");
- }
- int main(void){
- long arr[5] = {10,11,12,13,14};
- long nelements = 5;
- long constval = 5;
- printarr(&arr, nelements);
- long *arrb;
- arrb = move_to_function(&arr, nelements);
- printarr(arrb, nelements);
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement