Thread: error cant solve

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    1

    Unhappy error cant solve

    input is
    Code:
    #include<stdio.h>
    #include<string.h>
    #define S 10
    
    struct cricket
    
    {
    	char   	     player_name[30];
    	char   	     team_name[20];
    	float  	     batting_avg;
    }	player[S];
    linkfloat()
    {
    	float        x=0, *y;
    	y=&x;
    	x=*y;
    }
    main()
    {
    	void	     show_list(struct cricket player[]);
    	int	     i;
    	for(i=0;i<S;i++)
    	{
    		clrscr();
    		fflush(stdin);
    		printf("Enter the record for player - &#37;d", i+1);
    		printf("\n\nPlayer name : ");
    		gets(player[i].player_name);
    		printf("\nTeam name : ");
    		gets(player[i].team_name);
    		printf("\nBatting average : ");
    		scanf("%f", &player[i].batting_avg);
    	}
    	show_list(player);
    	printf("\n**** Good Bye ****\n");
    }
    void show_list(struct cricket player[]);
    {
    	char	      tname[30];
    		int	i,j,flag,count=0;
    	clrscr();
    	for(i=0;i<S;i++)
    	{
    		flag=1;
    		strcpy(tname,player[i],team_name);
    		for(j=i-1;j>=0;j--)
    		{
    			if(strcmp(tname,player[j].team_name)==0)
    			{
    				flag=0;
    				break;
    			}
    		}
    		if(flag)
    		{
    			count++;
    			printf("\n********* Team : %s *********\n\n\n", player[i].team_name);
    			print("				Player Name Batting Average\n\n");
    			printf("%30s%10.2f\n", player[i].player_name,player[i].batting_avg);
    			for(j=i+1;j<S;j++)
    			{
    				if(strcmp(tname,player[j].team_name)==0)
    				{
    					printf("%30s%10.2f\n", player[j].player_name,player[j].batting_avg);
    					count++;
    				}
    			}
    			if(count==S)
    			{
    				printf("\n\nAll player's data has been listed\n\n");
    				return;
    			}
    			else
    			{
    				printf("\n\nPress any key to continue....");
    				getch();
    				clrsrc();
    			}
    		}
    	}
    }
    output is
    i need output like this
    Enter the record for player - __________*/number*/

    player name :
    Team name:
    Batting average:

    Enter the record for player - __________*/number*/

    player name :
    Team name:
    Batting average:

    Enter the record for player - __________*/number*/

    player name :
    Team name:
    Batting average:

    Enter the record for player - __________*/number*/

    player name :
    Team name:
    Batting average:

    Enter the record for player - __________*/number*/

    player name :
    Team name:
    Batting average:
    all player's data has been listed
    **********good bye**********
    Last edited by Salem; 04-30-2007 at 05:07 AM. Reason: Use code tags in future!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    A good start would be to read the FAQ on why these things are bad.

    > fflush(stdin);
    > gets(player[i].player_name);

    Also, be more specific than "it doesn't work".
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can anyone solve this for me? (look inside)
    By johnsonswww in forum C Programming
    Replies: 10
    Last Post: 03-02-2009, 11:24 AM
  2. Replies: 2
    Last Post: 04-25-2005, 11:59 AM
  3. How to handle in software to solve this block diagram?
    By vnrabbit in forum C Programming
    Replies: 4
    Last Post: 02-13-2003, 02:45 PM
  4. Help to solve this problem
    By Romashka in forum C++ Programming
    Replies: 3
    Last Post: 04-16-2002, 09:32 AM