i still cant make it work :S
the program has to put integer into an array witht he use of pointers.
and also it should be able to check if there is an integer into the array, that the user wants ti find.
this is the whole code:
Code:
#include <stdio.h>
int A[5];
int *ptrI=A,*ptrF=A;
void insert(),find();
void insert() //user inserts vallues into the array
{int value;
for ( int i=0; i<5 ; i++)
{
printf("\n Doste enan akaireo arithmo : ");
scanf("%d",&value); //users value stored here
*ptrI=value; //value inserted with the use of pointer into the array
ptrI++; //pointer moves to the next array element
}
}
void find() //finds a value
{
int num;
printf("\n Parakalo doste enan akaireo arithmo : ");
scanf("%d",&num); //users value stored into num
for ( int i=0; i<5 ; i++) //scans the array. if users value= value of array element it prints the message. otherwise it goes into the next element(ptrF++)
{
if ( *ptrF==num)
{
printf("\n I timi yparxei ston pinaka sas !");
}
if ( *ptrF !=num)
{
ptrF++;
}
}
}
int main()
{
int ex=0;
do
{
int opt;
printf("\n 1.Eisagogi Stoixeiwn : ");
printf("\n 2.Euresi Stoixeiwn : ");
printf("\n 3.Telos programmatos : ");
scanf("%d",&opt);
if (opt==1)
{
insert();
}
if (opt==2)
{
find();
}
if (opt==3) // exit
{
ex=1;
}
}while (ex!=1);
}
the problem is that i am not familiar witht he use of pointers, and i cant get it right :S
any help is accepted as i have to deliver this to the university by e-mail by the end of the day, wich is 45 min away :P
i have sended it with this code, since i cant fix it, but i can resend it if i get the code right before midnight