Modify barcode. c (attached, Project 4, #2), the edge detection function using p
ID: 3669851 • Letter: M
Question
Modify barcode. c (attached, Project 4, #2), the edge detection function using pointer arithmetic. The function prototype should be the following. Name your program barcode2.c. void edge(int n, int *al, int *a2); The function should use pointer arithmetic - not subscripting - to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function. *This program finds the edges of light and dark regions of the *input binary bit pattern. #include void edge(int n, int a[], int b[]); int main(void) { int input[8]={0}; int output[8]; int i; printf("please enter the 8 bit bar code"); for(i=0;iExplanation / Answer
#include <stdio.h>
void edge(int n, int *a, int *b);
int main(void) {
int input[8] = {0};
int output[8];
printf("please enter the 8 bit bar code");
int count = 0;
while (count != 8) {
scanf("%1d", input + count);
++count;
}
edge(8, input, output);
count = 0;
while (count != 8) {
printf("%d", *(output + count));
count++;
}
return 0;
}
void edge(int n, int *a, int *b) {
*b = 0;
++a;
int count = 8;
while (count--) {
if (*a == *(a - 1))
*b = 0;
else
*b = 1;
++a;
++b;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.