i've done all the coding, but it doesn't work,
seem the if, cannot pass the information to the function..

#include<stdio.h>
#include <string.h>
#include<ctype.h>
#define FILENAME "ECE.txt"


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

 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>=600000 && matric<700000)
	{
	void proceed(struct registration com,int matric);
	}

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

		void again(struct registration com,int matric);
	}
	
	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");
	printf("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);

				do
				{
					printf("Enter subject code:");
					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");

					printf("Enter 1 if you wish to stop:");
					scanf("%d",&flag);

				}while(flag != 1);

			}

		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);

				do
				{
					printf("Enter subject code:");
					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");
					
					printf("Enter 1 if you wish to stop:");
					scanf("%d",&flag);
				}while(flag != 1);

			}
		}

	}
	
	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);

				do
				{
					printf("Enter subject code:");
					scanf("%s",com.code);
					/*if((strcmp(com.code,"END"))==0)
						break;*/

					printf("subject name:");
					scanf("%s",com.subject);
					printf("credit hour:");
					scanf("%d",&com.credit);
					puts("Thank you\n");
				
					printf("Enter 1 if you wish to stop:");
					scanf("%d",&flag);
				
				}while(flag != 1);


			}

		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);

				do
				{
					printf("Enter subject code:");
					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");
					
					printf("Enter 1 if you wish to stop:");
					scanf("%d",&flag);
				}while(flag != 1);

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

}
	
void again(struct registration com,int matric)
{

	int option,flag;
	char name[100];
	
	FILE *ECE;
	ECE = fopen(FILENAME, "r");
	printf("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);

				do
				{
					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");

					printf("Enter 1 if you wish to stop:");
					scanf("%d",&flag);

				}while(flag != 1);


			}

		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);
				
				do
				{
					printf("Enter subject code:");
					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");
				
					printf("Enter 1 if you wish to stop:");
					scanf("%d",&flag);

				}while(flag != 1);

			
			}
		}
}

Recommended Answers

All 3 Replies

You can't just give us a couple hundred lines of code and say that it doesn't work. What doesn't work, where does it fail, and what is the output?

One of the main problem is you are using constant more than int range , use float or long for it

float matric;

Or

long matric;

first Open your comments , because you prototype file name char name all these are closed in the comments symbol , don't use void inside main for calling a function just write the name of function and sending parameters .

Like proceed(com,metric)

don't write the data type with it .

Your mistake is

void proceed(struct registeration com,int matric)

make it

proceed(com,matric)
also
do the same procedure with your again funtion and Mark the thread solved if it solves your probelm.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.