So I tried to print elements of array after some point or place but its print me another number of garbage. The code need to print 7,8,9,5. I'm sure that the problem is in the line :
for (arr=x+1; arr < arr+ n; arr++) but I don't understand what to write instead this line.
Please help me and use * or & instead [](use pointers). thanks!
#include <stdio.h>
#include <stdlib.h>
void printAfterX(int* arr, int n, int* x);
int main(void)
{
int arr[] = { 4, 8, 6, 2, 1, 3, 5, 7, 8, 9, 5 };
printAfterX(arr, 11, arr + 6);
system("PAUSE");
return 0;
}
void printAfterX(int* arr, int n, int* x)
{
if (n >= arr)
{
printf("not found");
}
else
{
for (arr=x+1; arr < arr+ n; arr++)
{
printf("%d ",*arr);
}
}
}