Click here to Skip to main content
16,004,727 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
here i m making an aplication on school mgmt in c language.
nw my problem is i have declared my all the function. bt when i m using that functionin my code.
my compiler gives me a warning msg that " call to funtion with no prototype"

plz suggest me some solution for this kind of problem
thanks in advance

my code is below

C#
#include<conio.h>
#include<stdio.h>

int bubble(int*,int);
 void filewrite();
 void avgmarks();
 void fileprint();
 void filesort();
 void rollin();

/*********************** SORTING FUNCTION ***************************/
int bubble(int x[],int n)
{
 int hold,j,pass,i,switched = 1;
 for(pass = 0; pass < n-1 && switched == 1;pass++)
 {
  switched=0;
  for (j=0;j<n-pass-1;j++)
   if (x[j]>x[j+1])
   {
    switched=1;
    hold = x[j];
    x[j] = x[j+1];
    x[j+1]=hold;
    }
   }
return(0);
}
/*********************** FILE WRITING FUNCTION ******************************/
void filewrite()
{
  int roll,ch,mark;
  char nam[50];
   FILE *fp;
   clrscr();
  fp = fopen("student.txt","a");
   printf("ENTER ROLL NUMBER, NAME , MARKS \n");
  ch =1;
  while(ch)
  {
  scanf("%d%s%d",&roll,&nam,&mark);
  fprintf(fp,"%d %s %d\n",roll,nam,mark);
  printf("\n\n press 1 to continue,0 to stop");
  scanf("%d",&ch);
  }
   fclose(fp) ;
}
/******************** OUTPUTING DATA ON SCREEN***************/
void fileprint()
{
  int marks[100],rollno[100],x[100],i;
  char name[100][50];
  FILE *fp;

  clrscr();
  fp = fopen("student.txt","r");
   i=0;
   printf("ROLLNO       NAME        MARK\n");
   while(!feof(fp))
  {
     fscanf(fp,"%d %s %d\n",&rollno[i],&name[i],&marks[i]);
     printf(" %d          %s          %d\n",rollno[i],name[i],marks[i]);
     i=i+1;
   }
   fclose(fp);
   printf("\n\n\nPRESS ANY KEY");
   getch();

  }
/******************* SORTING FILE ************************/
void filesort()
  { int marks[100],rollno[100],x[100],n,i,j;
    char name[100][50];
    FILE *fp,*fm;

    fp = fopen("student.txt","r");
    fm = fopen("marks.txt","w");
    i=0;
   while(! feof(fp))
    {

     fscanf(fp,"%d %s %d\n",&rollno[i],&name[i],&marks[i]);
     x[i]= marks[i];
     i=i+1;
      }

       n=i;

       bubble(x,n);

    for(i=0;i<n;i++)
    {
    printf(" %d\t",x[i]);
    }

 for(i=0;i<n;i++)
 {
   for (j=0;j<n;j++)
   {
   if(x[i]==marks[j])
   {
      fprintf(fm,"%d %s %d\n",rollno[j],name[j],marks[j]);
     }
   }
 }
  fclose(fm);
  fclose(fp);
  printf("\n\n\nPRESS ANY KEY");
  getch();

}
/************************* DATA USING ROLLNO***************************/
void rollin()
{   int i,roll,ch,mark,roll1;
    char nam[50];
    FILE *fm;

    ch=1;
  while(ch)
  { clrscr();
    fm = fopen("marks.txt","r");
    printf(" \n ENTER ROLL NUMBER - ");
    scanf("%d",&roll1);
      i=0;
   while(! feof(fm))
    {
     fscanf(fm,"%d %s %d\n",&roll,&nam,&mark);
     if(roll1==roll)
    {printf("\nROLLNO.     NAME        MARKS\n ");
     printf(" %d          %s          %d\n",roll,nam,mark);
     break;
     }
     else
     i=i+1;
      }
  printf("\n\npress 1 to see student info, 0 to return to main menu\n");
  scanf("%d",&ch);
  fclose(fm);
  }



 }

void avgmarks()
 {
    int marks[100],rollno[100],n,i;
    float avg,x;
    char name[100][50];
    FILE *fm;
    fm = fopen("marks.txt","r");
    i=0;
   while(! feof(fm))
    {

     fscanf(fm,"%d %s %d\n",&rollno[i],&name[i],&marks[i]);
     x = x + marks[i];
     i=i+1;
      }
     n = i;
   avg = x/n;
  printf("AVERAGE MARKS OF %d STUDENTS ARE -  %f ",n,avg);
  fclose(fm);
  printf("\n\n\nPRESS ANY KEY");
   getch();

 }



void main()
{
  int marks[100],rollno[100],x[100],n,i,j,roll,c,mark,roll1;
  char name[100][10],nam[50];

  while(c!=6)
   {
     clrscr();
     printf("GIVE CHOICE--\n");
     printf("   1 TO ENTER STUDENT INFO.\n");
     printf("   2 TO SEE STUDENT.TXT FILE\n");
     printf("   3 TO SORT FILE ON BASIS OF MARKS\n");
     printf("   4 TO PRINT STUDENT INFO. USING ROLL NO\n");
     printf("   5 TO FIND AVERAGE OF MARKS\n");
     printf("   6 TO EXIT\n\n--");
     scanf("%d",&c);
     clrscr();
     switch(c)
     {
     case 1:
          filewrite();
          break;
     case 2:
          fileprint();
         break;
     case 3:
         filesort();
         break;
     case 4:  rollin();
          break;
     case 5:  avgmarks();
          break;
     case 6:
          break;
     default:
          break;
     }
    }
getch();
  }
Posted
Updated 11-Nov-13 5:54am
v4
Comments
Sergey Alexandrovich Kryukov 11-Nov-13 11:42am    
I would strongly advise you to modify the title of the question, as right now it creates a false impression that you wanted to call a function without prototype. Add some words indicating that this is an error message.
—SA
Richard MacCutchan 11-Nov-13 13:05pm    
Since all your functions appear in the file before they are referenced you do not need the prototypes.

The easiest thing to do is to prototype your function - you do that by writing a "short form" of the function definition at the top of the file, before you try call the function.
For example:
C++
int Add(int, int);   /* Prototype - before first use */
    
    int main (void)
        {
        return Add(3, 4);            /* First use */
        }
    
    int Add(int a, int b)            /* Function declaration */
        {
        return a + b;
        }
That way, the compiler gets to know what parameters to expect you to pass into and out of the function before you try to use it, and doesn't have to "back-track" to check them once it gets to the actual function declaration.
 
Share this answer
 
Comments
Member 10011989 11-Nov-13 11:57am    
yup i've done the same bt still i'm getting this warning.
wht to do?
OriginalGriff 11-Nov-13 12:02pm    
Which line is it warning on (I see you have posted the code now)?
Member 10011989 12-Nov-13 5:31am    
in cmy switch case code
OriginalGriff 12-Nov-13 6:02am    
OK - I just pasted your code into VS, and - once I'd provided a dummy method for crlscr - it compiled cleanly, exactly as it is in your example.

Exactly which line is it complaining about?
If possible, copy and paste the complete error message (and tell me which compiler / IDE you are using)
Albert Holguin 11-Nov-13 13:51pm    
Usually the compiler will tell you the line it has an issue with... Go to that line, see if function it is referring to has a prototype declaration and go from there (it's also possible that you're using a call with "no matching prototype" meaning there's something close but not right).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900