954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

but..

what about this one??
thanx, but when i've compile the program, it does not work
for the error, 'com' uses undefined struct 'registration'
and lots more

#include<stdio.h>
#include<ctype.h>
#define FILENAME "computing"


void proceed(struct registration com, int matric);
void again(struct registration com);

 struct registration
{
	char code[10];
	char subject[100];
	int credit;
};


int main()
{
	int matric;
	char name;

	FILE *ECE;
	ECE = fopen(FILENAME, "r");
	struct registration com;

	puts("Welcome to pre-registration for sem 1 2008/2009\n");
	puts("Enter your Matric number\n");
	scanf("%d", &matric);
	
	if(matric<700000 && matric>600000)

		proceed(struct registration com,matric);

	else if(matric>=700000 && matric<800000)
	{

		again(struct registration com);
	}
	else

		printf("Wrong ID\n");

	return 0;

}

void proceed(struct registration com, int matric)
{
	int option,flag;
	float CGPA;
	FILE *ECE;
	ECE = fopen(FILENAME, "r");
	print("Welcome %d\n",matric);
	puts("Enter current CGPA\n");
	scanf("%f",&CGPA);
	if(CGPA>=2.6 && CGPA<=4.0)
	{
		puts("\nmaximum credit hour is 18\n");
		puts("Choose option\n");
		puts("\n\t1 add subject\n\t2 drop subject\n");
		scanf("%d",&option);
		switch(option)
		
		{
		case 1:
			{
				puts("\nChoose subject below\n");
				while(fscanf(ECE,"%s %s %d",com.code,com.subject,&com.credit)!=EOF);
				{
					printf("subject code: %s\n subject name: %s\n credit hour: %d\n",com.code,com.subject, &com.credit);
				}

				fclose(ECE);

				while(flag==1){
					printf("Enter subject code(enter \'END\' when finished):");
					scanf("%[^\n]",com.code);
					if(strcmp(com.code,"END")==0)
						break;

					printf("subject name:");
					scanf("%[^\n]",com.subject);
					printf("credit hour:");
					scanf("%d",&com.credit);
					puts("Thank you\n");
				}

			}

		case 2:
			{
				FILE *ECE;
				ECE = fopen(FILENAME, "r");
				puts("choose subject to drop\n");
				while(fscanf(ECE,"%s %s %d",com.code,com.subject,&com.credit)!=EOF);
				{
					printf("subject code: %s\n subject name: %s\n credit hour: %d\n",com.code,com.subject, &com.credit);
				}
				
					fclose(ECE);

				while(flag==1){
					printf("Enter subject code(enter \'END\' when finished):");
					scanf("%[^\n]",com.code);
					if(strcmp(com.code,"END")==0)
						break;

					printf("subject name:");
					scanf("%[^\n]",com.subject);
					printf("credit hour:");
					scanf("%d",&com.credit);
					puts("Thank you\n");
				}
			}
		}
	}



	else if(CGPA>2.6 && CGPA<=2.4)
	{
		puts("\nmaximum credit hour is 15\n");
		puts("Choose option\n");
		puts("\n\t1 add subject\n\t2 drop subject\n");
		scanf("%d",&option);
		switch(option)
		
		{
		case 1:
			{
				puts("\nChoose subject below\n");
				while(fscanf(ECE,"%s %s %d",com.code,com.subject,&com.credit)!=EOF);
				{
					printf("subject code: %s\n subject name: %s\n credit hour: %d\n",com.code,com.subject, &com.credit);
				}

				fclose(ECE);

				while(flag==1){
					printf("Enter subject code(enter \'END\' when finished):");
					scanf("%[^\n]",com.code);
					if(strcmp(com.code,"END")==0)
						break;

					printf("subject name:");
					scanf("%[^\n]",com.subject);
					printf("credit hour:");
					scanf("%d",&com.credit);
					puts("Thank you\n");
				}

			}

		case 2:
			{
				FILE *ECE;
				ECE = fopen(FILENAME, "r");
				puts("choose subject to drop\n");
				while(fscanf(ECE,"%s %s %d",com.code,com.subject,&com.credit)!=EOF);
				{
					printf("subject code: %s\n subject name: %s\n credit hour: %d\n",com.code,com.subject, &com.credit);
				}
				
					fclose(ECE);

				while(flag==1){
					printf("Enter subject code(enter \'END\' when finished):");
					scanf("%[^\n]",com.code);
					if(strcmp(com.code,"END")==0)
						break;

					printf("subject name:");
					scanf("%[^\n]",com.subject);
					printf("credit hour:");
					scanf("%d",&com.credit);
					puts("Thank you\n");
				}
			}
		}
	}

	
	else if(CGPA > 2.4)
	{
		printf("You Have to see the dean\n");
	}

}
	
again(struct registration com);
{

	int option,flag;
	char name[];
	
	FILE *ECE;
	ECE = fopen(FILENAME, "r");
	print("Welcome %d\n",matric);
	puts("Enter your name\n");
	scanf("%s",name[]);
	puts("now, you can register\n");
	puts("\nmaximum credit hour is 18\n");
	puts("Choose option\n");
	puts("\n\t1 add subject\n\t2 drop subject\n");
	scanf("%d",&option);
	switch(option)
		
		{
		case 1:
			{
				puts("\nChoose subject below\n");
				while(fscanf(ECE,"%s %s %d",com.code,com.subject,&com.credit)!=EOF);
				{
					printf("subject code: %s\n subject name: %s\n credit hour: %d\n",com.code,com.subject, &com.credit);
				}

				fclose(ECE);

				while(flag==1){
					printf("Enter subject code(enter \'END\' when finished):");
					scanf("%[^\n]",com.code);
					if(strcmp(com.code,"END")==0)
						break;

					printf("subject name:");
					scanf("%[^\n]",com.subject);
					printf("credit hour:");
					scanf("%d",&com.credit);
					puts("Thank you\n");
				}

			}

		case 2:
			{
				FILE *ECE;
				ECE = fopen(FILENAME, "r");
				puts("choose subject to drop\n");
				while(fscanf(ECE,"%s %s %d",com.code,com.subject,&com.credit)!=EOF);
				{
					printf("subject code: %s\n subject name: %s\n credit hour: %d\n",com.code,com.subject, &com.credit);
				}
				
					fclose(ECE);

				while(flag==1){
					printf("Enter subject code(enter \'END\' when finished):");
					scanf("%[^\n]",com.code);
					if(strcmp(com.code,"END")==0)
						break;

					printf("subject name:");
					scanf("%[^\n]",com.subject);
					printf("credit hour:");
					scanf("%d",&com.credit);
					puts("Thank you\n");
				}
			}
		}
	}
}
fiz hafiz
Newbie Poster
5 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

line 6: it would be more efficient if you passed the structure by reference (pointer) instead of by value. Note the asterisk below. You have to make similar change in the actual function.
void proceed(struct registration* com, int matric);

line 32 and other similar lines -- you don't put the data type in the parameter list, just the names of the variables you want to pass to the function.

You have lots and lots of other errors and missing parameters. Look at each error message that your compiler produced and fix them one at a time. Recompile after each fix to remove other related errors that are not necessary to fix. Then after fixing the compile errors you will have to deal with the logic errors.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

When you read the Community Rules, what part of this rule did you not understand?

WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You