Thanks a lot!
Finally my programm got compiled, thanks to you!
Now I have other problems. I get a lot of ununderstanding numbers printing on the screen, and at the end the message segmantation fault.
I will copy my whole programm, but I think the mistake has to do with the pointers which I can't understand very well.
Code:
#include <stdio.h>
#define MaxSize 300
#define First 0
void PrintTable(int T[], int Last);
void Insert(int T [], int elem, int pos, int* Last);
void Delete(int T[],int pos, int* Last);
void DeleteMult(int T[], int* Last);
main()
{
int *Last;
int T[MaxSize];
int l, elem, pos;
//Reading the table
FILE *pT;
pT = fopen("tab.dat","r");
Last=&T[0];
//Printing the table <<<<----------------------Where the problem starts
PrintTable(T, *Last);
//-----------------------------------------------------------------------------------------------//
//Dialog between Computer-User
printf("Which application do you want to use?:\n1-> Insert \n2->Delete \n3->DeleteMult\n Please give the number");
printf("of the application:");
scanf("%i",&l);
printf("\n");
//Dialog for Insert
if (l=1)
{
printf("Please give the number you want to insert:");
scanf("%i",&elem);
printf("\nAnd the place for it to be inserted:");
scanf("%i",&pos);
Insert(T, elem, pos, Last);
printf("\nThe element has been inserted\n");
PrintTable(T, *Last);
}
//Dialog for Delete
else if (l=2)
{
printf("Please give the number you want to delete:");
scanf("%i",&pos);
Delete(T, pos, Last);
printf("\nThe element has been deleted\n");
PrintTable(T, *Last);
}
//Dialog for DeleteMult
else if (l=3)
{
DeleteMult(T, Last);
printf("The application is finished\n");
PrintTable(T, *Last);
}
else
//If the application number is false:
printf("The application number can only be 1 2 i 3\n");
//-----------------------------------------------------------------------------------------
}
//*******************************************************//
//*********************FUNCTIONS*************************//
//*******************************************************//
void PrintTable(int T[], int Last)
{
int i;
for(i=1; i<Last; ++i)
{ if(i%12==0)
printf("%4d\n",T[i],"\v");
else
printf("%4d",T[i],"\v");
}
}
//////////////////////////////////////////////////////
void Insert(int T[], int elem, int pos, int *Last)
{
int i;
if(pos>=First & pos<=*Last & *Last<MaxSize)
{ for (i=*Last; i=pos; i--)
{
T[i+1]=T[i];
}
T[pos]= elem;
Last= Last+1;
}
else
printf("I thesi pos vrisketai ektos tou pinaka T\n");
}
//////////////////////////////////////////////////////
void Delete(int T[], int pos, int* Last)
{
int i;
if(pos=*Last)
{
T[pos]=0;
*Last=*Last-1;
}
else if (pos<*Last & pos >=First)
{
for(i=pos; i=pos-1; ++i)
T[i]=T[i+1];
Last=Last-1;
}
else
printf("Den Iparxei stoixeio se aythn thn thesi i den iparxei i thesi ston pinaka\n");
}
///////////////////////////////////////////////////////
void DeleteMult(int T[], int* Last)
{
int i, k;
for(i=First+1; i<=*Last; ++i)
for(k=First; k<=i-1; ++k)
if(T[i]=T[k])
Delete( T, i, Last);
}
Thats it! Sorry for posting so much code.
I can't upload the data file, but it has 256 numbers, the first is not for the table, it is the number 255 which says us how many numbers the file has. So Last must be the T[255] at the start.
Sorry, again, and I hope that you help me!