Pointer Practice.c - #include#include#include#include#include <stdio.h> <assert.h> <stdlib.h> <time.h> <string.h> void swap(int*ptr1 int*ptr2 int temp

Pointer Practice.c -...

This preview shows page 1 out of 1 page.

#include <stdio.h> #include <assert.h> #include <stdlib.h> #include <time.h> #include <string.h> void swap(int *ptr1, int *ptr2) { int temp = *ptr2; *ptr2 = *ptr1; *ptr1 = temp; } int main() { //copy one array to another using pointers int input1; printf("Enter pls \n"); scanf("%d", &input1); int *arr1 = (int *)malloc(input1 * sizeof(int*)); //int *arr2 = (int *)malloc(input1 * sizeof(int*)); int arr2[input1]; int *ptr = arr1; //pointer to 1st elem
Image of page 1

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture