#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);
	
	/*f(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");
	puts("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);
				}

			}

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

i'm not finish yet, but, is this the way??
there's lot of error, and i'm not sure what is it!!
can i just copy the first code to use for other CGPA and for the other function header for the students who are not in the record??
the data file will contain the subjects name with the code and credit hour

Recommended Answers

All 2 Replies

line 53: you have to use printf() to do that. puts() only accepts one parameter and that is the string that is to be displayed.

I don't know what other errors you want to know about. You'll have to be very specific.

#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);
	
	/*f(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");
	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);

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

			}

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

i'm not finish yet, but, is this the way??
there's lot of error, and i'm not sure what is it!!
can i just copy the first code to use for other CGPA and for the other function header for the students who are not in the record??
the data file will contain the subjects name with the code and credit hour

ERROR IN LINE 53 --->

You cannot serve more than 1 arument here, 'cause puts() accepts only 1 argument. i.e array name or string to be printed..

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.