#include"stdio.h"
#include"conio.h"
#include"process.h"
#include"ctype.h"
#include"string.h"
#include"io.h"
#include"fcntl.h"

#define length 1

struct StudentInfo
{
	char studentid[8];
	char lastname[15];
	char firstname[15];
	char middlename[15];
	char gender[6];
	char birthdate[15];
	char age[3];
	char contactno[15];
	char guardian[30];
	char address[120];
};

struct tmp
{
	char studentid[8];
	char lastname[15];
	char firstname[15];
	char middlename[15];
	char gender[6];
	char birthdate[15];
	char age[3];
	char contactno[15];
	char guardian[30];
	char address[120];
};

StudentInfo var[length];
int rea = -1, top = -1;

FILE *ptr;

void refresh()
{
	fclose(ptr);
	ptr = fopen("c:\\file.txt","a+");
}

int filesize()
{
	int des;

	des=open("c:\\file.txt",O_RDONLY,0);
	des=lseek(des,0,SEEK_END);

	return length;
}

int getNoOfRecords()
{
	return(filesize()/(sizeof(struct StudentInfo)));
}

void addStudentRecord()
{
	char ans;
	int x,y;
	clrscr();
	tmp s;


	for(y=0; y<8; y++)
	{

		s.studentid[y]='\0';
	}
	for(y=0; y<15; y++)
	{
		s.lastname[y]='\0';
		s.firstname[y]='\0';
		s.middlename[y]='\0';
		s.birthdate[y]='\0';
		s.contactno[y]='\0';
	}
	for(y=0; y<6; y++)
	{
		s.gender[y]='\0';
	}
	for(y=0; y<3; y++)
	{
		s.age[y]='\0';
	}
	for(y=0; y<30; y++)
	{
		s.guardian[y]='\0';
	}
	for(y=0; y<120; y++)
	{
		s.address[y]='\0';
	}


	printf("\n\nADD STUDENT RECORD MODULE\n\n");

	if(top!=length-1)
	{
		printf("Student ID: ");
		gets(s.studentid);
		printf("Lastname: ");
		gets(s.lastname);
		printf("Firstname: ");
		gets(s.firstname);
		printf("Middlename: ");
		gets(s.middlename);
		printf("Gender: ");
		gets(s.gender);
		printf("Birthdate: ");
		gets(s.birthdate);
		printf("Age: ");
		gets(s.age);
		printf("Contact Number: ");
		gets(s.contactno);
		printf("Guardian: ");
		gets(s.guardian);
		printf("Address: ");
		gets(s.address);
		printf("\n\n");
	}

	printf("Do you want to save<Y/N>?\n\n");
	ans = getche();

	if(toupper(ans)=='Y')
	{
		strcpy(var[top+1].studentid,s.studentid);
		strcpy(var[top+1].lastname,s.lastname);
		strcpy(var[top+1].firstname,s.firstname);
		strcpy(var[top+1].middlename,s.middlename);
		strcpy(var[top+1].gender,s.gender);
		strcpy(var[top+1].birthdate,s.birthdate);
		strcpy(var[top+1].age,s.age);
		strcpy(var[top+1].contactno,s.contactno);
		strcpy(var[top+1].guardian,s.guardian);
		strcpy(var[top+1].address,s.address);
	}

	fwrite(&var[x],sizeof(struct StudentInfo),1,ptr);


	printf("\nData Entered Successfully!!!\n");
	getch();
}

void updateStudentRecord()
{
	char studentid[8];
	int records = getNoOfRecords();
	int x,counter=0;

	clrscr();
	printf("\n\nUPDATE STUDENT RECORD MODULE\n\n");
	for(x=0; x<length; x++)
	{
		printf("Student ID: ");
		gets(var[x].studentid);

		while(counter!=records)
		{
			fread(&var[x],sizeof(struct StudentInfo),1,ptr);
			if(var[x].studentid==studentid)
			{

			}
			counter++;
		}
		printf("\n\n");
	}
	printf("Data Entered Successfully Updated!!!\n\n");
	getch();
}

void deleteStudentRecord()
{
	char studentid[8];
	int records=getNoOfRecords();
	int x,counter=0;

	FILE *ptr2 = fopen("c:\\file2.txt","a");

	clrscr();
	printf("\n\nDELETE STUDENT RECORD MODULE\n\n");
	for(x=0; x<length; x++)
	{
		printf("Student ID: ");
		gets(var[x].studentid);

		while(counter!=records)
		{
			fread(&var[x],sizeof(struct StudentInfo),1,ptr);
			if(var[x].studentid==studentid)
			{

			}
			else
			{
				fwrite(&var[x],sizeof(struct StudentInfo),1,ptr2);
			}
			counter++;
		}
		printf("\n\n");
	}
	fcloseall();
	remove("c:\\file.txt");
	rename("c:\\file2.txt","c:\\file.txt");
	printf("Data Successfully Deleted!!!\n\n");
	getch();
}

void print()
{
	int x;

	clrscr();
	for(x=0; x<length; x++)
	{
		printf("\nStudent ID: ");
		puts(var[x].studentid);
		printf("\nLastname: ");
		puts(var[x].lastname);
		printf("\nFirstname: ");
		puts(var[x].firstname);
		printf("\nMiddlename: ");
		puts(var[x].middlename);
		printf("\nGender: ");
		puts(var[x].gender);
		printf("\nBirthdate: ");
		puts(var[x].birthdate);
		printf("\nAge: ");
		puts(var[x].age);
		printf("\nContact Number: ");
		puts(var[x].contactno);
		printf("\nGuardian: ");
		puts(var[x].guardian);
		printf("\nAddress: ");
		puts(var[x].address);
		printf("\n\n");
	}
	getch();
}

void searchStudentRecord()
{
	char studentid[8];
	int records=getNoOfRecords();
	int x,y,counter=0;

	clrscr();
	printf("\n\nSEARCH STUDENT RECORD MODULE\n\n");
	for(x=0; x<length; x++)
	{
		printf("Student ID: ");
		gets(var[x].studentid);

		while(counter!=records)
		{
			fread(&var[x],sizeof(struct StudentInfo),1,ptr);
			if(var[x].studentid==studentid)
			{
				print();
			}
			counter++;
		}
	}


	for(x=0; x<length; x++)
	{
		printf("\nStudent ID: %s",var[x].studentid);
		printf("\nLastname: %s",var[x].lastname);
		printf("\nFirstname: %s",var[x].firstname);
		printf("\nMiddlename: %s",var[x].middlename);
		printf("\nGender: %s",var[x].gender);
		printf("\nBirthdate: %s",var[x].birthdate);
		printf("\nAge: %s",var[x].age);
		printf("\nContact Number: %s",var[x].contactno);
		printf("\nGuardian: %s",var[x].guardian);
		printf("\nAddress: %s",var[x].address);
		printf("\n\n");
	}
	getch();
}

void displayAllRecords()
{
	int x,y;
	clrscr();
	tmp s;

	for(y=0; y<8; y++)
	{
		s.studentid[y]='\0';
	}
	for(y=0; y<15; y++)
	{
		s.lastname[y]='\0';
		s.firstname[y]='\0';
		s.middlename[y]='\0';
		s.birthdate[y]='\0';
		s.contactno[y]='\0';
	}
	for(y=0; y<6; y++)
	{
		s.gender[y]='\0';
	}
	for(y=0; y<3; y++)
	{
		s.age[y]='\0';
	}
	for(y=0; y<30; y++)
	{
		s.guardian[y]='\0';
	}
	for(y=0; y<120; y++)
	{
		s.address[y]='\0';
	}

	printf("\n\nDISPLAY ALL RECORDS MODULE\n\n");

	for(x=0; x<length; x++)
	{
		printf("\nStudent ID: %s",var[x].studentid);
		printf("\nLastname: %s",var[x].lastname);
		printf("\nFirstname: %s",var[x].firstname);
		printf("\nMiddlename: %s",var[x].middlename);
		printf("\nGender: %s",var[x].gender);
		printf("\nBirthdate: %s",var[x].birthdate);
		printf("\nAge: %s",var[x].age);
		printf("\nContact Number: %s",var[x].contactno);
		printf("\nGuardian: %s",var[x].guardian);
		printf("\nAddress: %s",var[x].address);
		printf("\n\n");
	}
	getch();
}

void printStudentRecord()
{
	StudentInfo var[length];
	int x,y;

	clrscr();
	printf("\n\nPRINT STUDENT RECORD MODULE\n\n");
	for(x=0; x<length; x++)
	{
		for(y=0; y<length; y++)
		{
			var[x].studentid[y]='\0';
			var[x].lastname[y]='\0';
			var[x].firstname[y]='\0';
			var[x].middlename[y]='\0';
			var[x].gender[y]='\0';
			var[x].birthdate[y]='\0';
			var[x].age[y]='\0';
			var[x].contactno[y]='\0';
			var[x].guardian[y]='\0';
			var[x].address[y]='\0';
		}
	}
	for(x=0; x<length; x++)
	{
		printf("\nStudent ID: %s",var[x].studentid);
		printf("\nLastname: %s",var[x].lastname);
		printf("\nFirstname: %s",var[x].firstname);
		printf("\nMiddlename: %s",var[x].middlename);
		printf("\nGender: %s",var[x].gender);
		printf("\nBirthdate: %s",var[x].birthdate);
		printf("\nAge: %s",var[x].age);
		printf("\nContact Number: %s",var[x].contactno);
		printf("\nGuardian: %s",var[x].guardian);
		printf("\nAddress: %s",var[x].address);
		printf("\n\n");
	}
	getch();
}

void lines()
{
	printf("\n\n\t\t\t-------------------------");
}

void main()
{
	char choice;
	int x,y;

	for(x=0; x<length; x++)
	{
		for(y=0; y<length; y++)
		{
			var[x].studentid[y]='\0';
			var[x].lastname[y]='\0';
			var[x].firstname[y]='\0';
			var[x].middlename[y]='\0';
			var[x].gender[y]='\0';
			var[x].birthdate[y]='\0';
			var[x].age[y]='\0';
			var[x].contactno[y]='\0';
			var[x].guardian[y]='\0';
			var[x].address[y]='\0';
		}
	}

	ptr=fopen("c:\\file.txt","a+");

	for(;;)
	{
		textbackground(MAGENTA);
		textcolor(YELLOW);
		clrscr();
		lines();
		printf("\n\n\t\t\t STATIC RECORD HANDLING");
		lines();
		printf("\n\n\t\t\t(1.) Add Record\n");
		printf("\n\t\t\t(2.) Update Record\n");
		printf("\n\t\t\t(3.) Delete Record\n");
		printf("\n\t\t\t(4.) Search Record\n");
		printf("\n\t\t\t(5.) Display Record\n");
		printf("\n\t\t\t(6.) Print Record\n");
		printf("\n\t\t\t(7.) Exit/Quit\n");
		printf("\n\n\n\t\t\tPress <1-7> Transactions!\n\n");
		printf("\n\n\n\t\t\tProgrammed by:\n");
		printf("\n\n\t\t\tRichard B. Juevesano\n");
		printf("\n\t\t\tBSIT-1\n");
		choice=getche();

		switch(choice)
		{
			case '1':
				addStudentRecord();
				break;
			case '2':
				updateStudentRecord();
				break;
			case '3':
				deleteStudentRecord();
				break;
			case '4':
				searchStudentRecord();
				break;
			case '5':
				displayAllRecords();
				break;
			case '6':
				printStudentRecord();
				break;
			case '7':
				exit(0);
				break;
		}
	}

}
/*_________________________END_______________________________________*/

Dani AI

Generated

Several people already flagged formatting and missing details (, , ). The code compiles but the update/delete paths fail because of a handful of logic and I/O mistakes rather than a single mysterious compiler bug. Below are the concrete problems to fix and practical, minimal steps to make update/delete work reliably.

Key bugs and fixes

  • String comparison: expressions like var[x].studentid == studentid compare addresses, not content. Use strcmp() (or std::string and == in C++) and check strcmp(...) == 0.
  • Loop/index logic: constructs such as while(top != rear) and uses of var[top+1] cause infinite loops and out‑of‑bounds access. Keep a single record count (e.g. top as last index) and iterate for (i = 0; i <= top; ++i) when scanning. Check capacity with top < length - 1 before adding.
  • File I/O modes: opening with "a+" forces writes to append; it cannot overwrite an existing record. For in‑place updates use read/write binary mode ("r+b" / "r+") with fseek to the record offset, or rewrite the whole file. For delete, copy records to a temp file and rename, or shift in memory and rewrite.
  • Initialization and safety: replace gets() (unsafe and obsolete) with fgets() or C++ std::getline, use strncpy with explicit null terminators, and zero buffers with memset instead of many small loops. Always check fopen, fread, fwrite return values.

Recommended workflows (no full code here)

  • Update: read the ID, find the index via strcmp. If found, collect new fields safely, update the in‑memory array, then either fseek(fp, index*sizeof(StudentInfo), SEEK_SET) and fwrite that single struct, or reopen the file for write and dump all records.
  • Delete: find index, shift subsequent array elements left, decrement top, then rewrite the file from 0 to top. Alternatively, when operating on file directly, copy all non‑matching records to a temp file and rename.

Other notes

  • The filesize() function in the first post returns length by mistake; use fseek/ftell (or stat) to get real file size.
  • Consider modernizing: std::vector + std::string simplify bounds and copying, and remove dependence on conio.h.
  • Add simple debug prints of indices and counts while testing. pointed out include/portability issues; and were right about posting code with tags so future helpers can read it.

Recommended Answers

All 9 Replies

You need to post what it is your having trouble with, things you've tried on your own already and what the expected result should be. Posting code alone is not sufficient for understanding your question. Also, next time, please wrap your code in the proper tags.

Did you forget to read the Rules and the post Read This Before Posting?

How about all the information on CODE tags like
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) Even on the background of the box you actually typed your message in!

1) Use code tags.
2) #include "blah.h" tells compiler to look into the project directory
for the file. Libraries like string and cctype are not in your directory
and so use #include<blah> syntax.
3) Whats your problem?

//adjusted a little
#include<stdio.h>
#include<conio.h> //non standard
#include<process.h>
#include<ctype.h>
#include<string.h>
#include<io.h>
#include<fcntl.h>

#define length 1

struct StudentInfo
{
    char studentid[8];
    char lastname[15];
    char firstname[15];
    char middlename[15];
    char gender[6];
    char birthdate[15];
    char age[3];
    char contactno[15];
    char guardian[30];
    char address[120];
};

struct tmp
{
    char studentid[8];
    char lastname[15];
    char firstname[15];
    char middlename[15];
    char gender[6];
    char birthdate[15];
    char age[3];
    char contactno[15];
    char guardian[30];
    char address[120];
};

StudentInfo var[length];
//GLOBAL IS BAD
int rea = -1, top = -1;

FILE *ptr;

void refresh()
{
    fclose(ptr);
    ptr = fopen("c:\\file.txt","a+");
}

int filesize()
{
    int des;

    des=open("c:\\file.txt",O_RDONLY,0);
    des=lseek(des,0,SEEK_END);

    return length;
}

int getNoOfRecords()
{
    return(filesize()/(sizeof(struct StudentInfo)));
}

void addStudentRecord()
{
    char ans;
    int x,y;
    clrscr();
    tmp s;

for(y=0; y<8; y++)
{
    s.studentid[y]='\0';
}
for(y=0; y<15; y++)
{
    s.lastname[y]='\0';
    s.firstname[y]='\0';
    s.middlename[y]='\0';
    s.birthdate[y]='\0';
    s.contactno[y]='\0';
}
for(y=0; y<6; y++)
{
    s.gender[y]='\0';
}
for(y=0; y<3; y++)
{
    s.age[y]='\0';
}
for(y=0; y<30; y++)
{
    s.guardian[y]='\0';
}
for(y=0; y<120; y++)
{
    s.address[y]='\0';
}


printf("\n\nADD STUDENT RECORD MODULE\n\n");

if(top!=length-1)
{
    printf("Student ID: ");
    gets(s.studentid);
    printf("Lastname: ");
    gets(s.lastname);
    printf("Firstname: ");
    gets(s.firstname);
    printf("Middlename: ");
    gets(s.middlename);
    printf("Gender: ");
    gets(s.gender);
    printf("Birthdate: ");
    gets(s.birthdate);
    printf("Age: ");
    gets(s.age);
    printf("Contact Number: ");
    gets(s.contactno);
    printf("Guardian: ");
    gets(s.guardian);
    printf("Address: ");
    gets(s.address);
    printf("\n\n");
}

    printf("Do you want to save<Y/N>?\n\n");
    ans = getche();
    
if(toupper(ans)=='Y')
{
    strcpy(var[top+1].studentid,s.studentid);
    strcpy(var[top+1].lastname,s.lastname);
    strcpy(var[top+1].firstname,s.firstname);
    strcpy(var[top+1].middlename,s.middlename);
    strcpy(var[top+1].gender,s.gender);
    strcpy(var[top+1].birthdate,s.birthdate);
    strcpy(var[top+1].age,s.age);
    strcpy(var[top+1].contactno,s.contactno);
    strcpy(var[top+1].guardian,s.guardian);
    strcpy(var[top+1].address,s.address);
}

    fwrite(&var[x],sizeof(struct StudentInfo),1,ptr);
    printf("\nData Entered Successfully!!!\n");
    getch();
}

void updateStudentRecord()
{
    char studentid[8];
    int records = getNoOfRecords();
    int x,counter=0;
    
    clrscr();
    printf("\n\nUPDATE STUDENT RECORD MODULE\n\n");
for(x=0; x<length; x++)
{
    printf("Student ID: ");
    gets(var[x].studentid);

while(counter!=records)
{
    fread(&var[x],sizeof(struct StudentInfo),1,ptr);
    if(var[x].studentid==studentid){
    }
    counter++;
}
    printf("\n\n");
}
    printf("Data Entered Successfully Updated!!!\n\n");
    getch();
}

void deleteStudentRecord()
{
    char studentid[8];
    int records=getNoOfRecords();
    int x,counter=0;
    
    FILE *ptr2 = fopen("c:\\file2.txt","a");

    clrscr();
    printf("\n\nDELETE STUDENT RECORD MODULE\n\n");
for(x=0; x<length; x++)
{
    printf("Student ID: ");
    gets(var[x].studentid);

while(counter!=records)
{
    fread(&var[x],sizeof(struct StudentInfo),1,ptr);
    if(var[x].studentid==studentid)
{

}
else
{
    fwrite(&var[x],sizeof(struct StudentInfo),1,ptr2);
}
    counter++;
}
    printf("\n\n");
}
    fcloseall();
    remove("c:\\file.txt");
    rename("c:\\file2.txt","c:\\file.txt");
    printf("Data Successfully Deleted!!!\n\n");
    getch();
}

void print()
{
    int x;

    clrscr();
for(x=0; x<length; x++)
{
    printf("\nStudent ID: ");
    puts(var[x].studentid);
    printf("\nLastname: ");
    puts(var[x].lastname);
    printf("\nFirstname: ");
    puts(var[x].firstname);
    printf("\nMiddlename: ");
    puts(var[x].middlename);
    printf("\nGender: ");
    puts(var[x].gender);
    printf("\nBirthdate: ");
    puts(var[x].birthdate);
    printf("\nAge: ");
    puts(var[x].age);
    printf("\nContact Number: ");
    puts(var[x].contactno);
    printf("\nGuardian: ");
    puts(var[x].guardian);
    printf("\nAddress: ");
    puts(var[x].address);
    printf("\n\n");
}
    getch();
}

void searchStudentRecord()
{
char studentid[8];
int records=getNoOfRecords();
int x,y,counter=0;

clrscr();
printf("\n\nSEARCH STUDENT RECORD MODULE\n\n");
for(x=0; x<length; x++)
{
printf("Student ID: ");
gets(var[x].studentid);

while(counter!=records)
{
fread(&var[x],sizeof(struct StudentInfo),1,ptr);
if(var[x].studentid==studentid)
{
print();
}
counter++;
}
}


for(x=0; x<length; x++)
{
printf("\nStudent ID: %s",var[x].studentid);
printf("\nLastname: %s",var[x].lastname);
printf("\nFirstname: %s",var[x].firstname);
printf("\nMiddlename: %s",var[x].middlename);
printf("\nGender: %s",var[x].gender);
printf("\nBirthdate: %s",var[x].birthdate);
printf("\nAge: %s",var[x].age);
printf("\nContact Number: %s",var[x].contactno);
printf("\nGuardian: %s",var[x].guardian);
printf("\nAddress: %s",var[x].address);
printf("\n\n");
}
getch();
}

void displayAllRecords()
{
int x,y;
clrscr();
tmp s;

for(y=0; y<8; y++)
{
s.studentid[y]='\0';
}
for(y=0; y<15; y++)
{
s.lastname[y]='\0';
s.firstname[y]='\0';
s.middlename[y]='\0';
s.birthdate[y]='\0';
s.contactno[y]='\0';
}
for(y=0; y<6; y++)
{
s.gender[y]='\0';
}
for(y=0; y<3; y++)
{
s.age[y]='\0';
}
for(y=0; y<30; y++)
{
s.guardian[y]='\0';
}
for(y=0; y<120; y++)
{
s.address[y]='\0';
}

printf("\n\nDISPLAY ALL RECORDS MODULE\n\n");

for(x=0; x<length; x++)
{
printf("\nStudent ID: %s",var[x].studentid);
printf("\nLastname: %s",var[x].lastname);
printf("\nFirstname: %s",var[x].firstname);
printf("\nMiddlename: %s",var[x].middlename);
printf("\nGender: %s",var[x].gender);
printf("\nBirthdate: %s",var[x].birthdate);
printf("\nAge: %s",var[x].age);
printf("\nContact Number: %s",var[x].contactno);
printf("\nGuardian: %s",var[x].guardian);
printf("\nAddress: %s",var[x].address);
printf("\n\n");
}
getch();
}

void printStudentRecord()
{
StudentInfo var[length];
int x,y;

clrscr();
printf("\n\nPRINT STUDENT RECORD MODULE\n\n");
for(x=0; x<length; x++)
{
for(y=0; y<length; y++)
{
var[x].studentid[y]='\0';
var[x].lastname[y]='\0';
var[x].firstname[y]='\0';
var[x].middlename[y]='\0';
var[x].gender[y]='\0';
var[x].birthdate[y]='\0';
var[x].age[y]='\0';
var[x].contactno[y]='\0';
var[x].guardian[y]='\0';
var[x].address[y]='\0';
}
}
for(x=0; x<length; x++)
{
printf("\nStudent ID: %s",var[x].studentid);
printf("\nLastname: %s",var[x].lastname);
printf("\nFirstname: %s",var[x].firstname);
printf("\nMiddlename: %s",var[x].middlename);
printf("\nGender: %s",var[x].gender);
printf("\nBirthdate: %s",var[x].birthdate);
printf("\nAge: %s",var[x].age);
printf("\nContact Number: %s",var[x].contactno);
printf("\nGuardian: %s",var[x].guardian);
printf("\nAddress: %s",var[x].address);
printf("\n\n");
}
getch();
}

void lines()
{
printf("\n\n\t\t\t-------------------------");
}

void main()
{
char choice;
int x,y;

for(x=0; x<length; x++)
{
for(y=0; y<length; y++)
{
var[x].studentid[y]='\0';
var[x].lastname[y]='\0';
var[x].firstname[y]='\0';
var[x].middlename[y]='\0';
var[x].gender[y]='\0';
var[x].birthdate[y]='\0';
var[x].age[y]='\0';
var[x].contactno[y]='\0';
var[x].guardian[y]='\0';
var[x].address[y]='\0';
}
}

ptr=fopen("c:\\file.txt","a+");

for(;
{
textbackground(MAGENTA);
textcolor(YELLOW);
clrscr();
lines();
printf("\n\n\t\t\t STATIC RECORD HANDLING");
lines();
printf("\n\n\t\t\t(1.) Add Record\n");
printf("\n\t\t\t(2.) Update Record\n");
printf("\n\t\t\t(3.) Delete Record\n");
printf("\n\t\t\t(4.) Search Record\n");
printf("\n\t\t\t(5.) Display Record\n");
printf("\n\t\t\t(6.) Print Record\n");
printf("\n\t\t\t(7.) Exit/Quit\n");
printf("\n\n\n\t\t\tPress <1-7> Transactions!\n\n");
printf("\n\n\n\t\t\tProgrammed by:\n");
printf("\n\n\t\t\tRichard B. Juevesano\n");
printf("\n\t\t\tBSIT-1\n");
choice=getche();

switch(choice)
{
case '1':
addStudentRecord();
break;
case '2':
updateStudentRecord();
break;
case '3':
deleteStudentRecord();
break;
case '4':
searchStudentRecord();
break;
case '5':
displayAllRecords();
break;
case '6':
printStudentRecord();
break;
case '7':
exit(0);
break;
}
}

}
/*_________________________END_______________________________________*/

this is my program in static record handling... there's so many changes i have done... now i am now trying to update , delete record but i can't delete , update a record... there's something wrong in my program.. actually, it will compile... can you help me in my project??

here is my program:

#include"stdio.h"
#include"conio.h"
#include"process.h"
#include"ctype.h"
#include"string.h"

#define length 5

struct StudentInfo
{
	char studentid[8];
	char lastname[15];
	char firstname[15];
	char middlename[15];
	char gender[6];
	char birthdate[15];
	char age[3];
	char contactno[15];
	char guardian[30];
	char address[120];
};

struct tmp
{
	char studentid[8];
	char lastname[15];
	char firstname[15];
	char middlename[15];
	char gender[6];
	char birthdate[15];
	char age[3];
	char contactno[15];
	char guardian[30];
	char address[120];
};

StudentInfo var[length];
int rear = -1, top = -1;


void addStudentRecord()
{
	char ans;
	int y;
	clrscr();

	tmp s;

	for(y=0; y<8; y++)
	{
		s.studentid[y]='\0';
	}
	for(y=0; y<15; y++)
	{
		s.lastname[y]='\0';
		s.firstname[y]='\0';
		s.middlename[y]='\0';
		s.birthdate[y]='\0';
		s.contactno[y]='\0';
	}
	for(y=0; y<6; y++)
	{
		s.gender[y]='\0';
	}
	for(y=0; y<3; y++)
	{
		s.age[y]='\0';
	}
	for(y=0; y<30; y++)
	{
		s.guardian[y]='\0';
	}
	for(y=0; y<120; y++)
	{
		s.address[y]='\0';
	}


	printf("\n\nADD STUDENT RECORD MODULE\n\n");

	if(top<length)
	{
		printf("Student ID: ");
		gets(s.studentid);
		printf("Lastname: ");
		gets(s.lastname);
		printf("Firstname: ");
		gets(s.firstname);
		printf("Middlename: ");
		gets(s.middlename);
		printf("Gender: ");
		gets(s.gender);
		printf("Birthdate: ");
		gets(s.birthdate);
		printf("Age: ");
		gets(s.age);
		printf("Contact Number: ");
		gets(s.contactno);
		printf("Guardian: ");
		gets(s.guardian);
		printf("Address: ");
		gets(s.address);
		printf("\n\n");
	}

	printf("Do you want to save <Y/N>?\n\n");
	ans = getche();

	if(toupper(ans) == 'Y')
	{
		top++;
		strcpy(var[top].studentid,s.studentid);
		strcpy(var[top].lastname,s.lastname);
		strcpy(var[top].firstname,s.firstname);
		strcpy(var[top].middlename,s.middlename);
		strcpy(var[top].gender,s.gender);
		strcpy(var[top].birthdate,s.birthdate);
		strcpy(var[top].age,s.age);
		strcpy(var[top].contactno,s.contactno);
		strcpy(var[top].guardian,s.guardian);
		strcpy(var[top].address,s.address);
	}
	getch();
}

void updateStudentRecord()
{
	char studentid[8];
	int counter = 0;

	clrscr();
	printf("\n\nUPDATE STUDENT RECORD MODULE\n\n");
	printf("Student ID: ");
	gets(studentid);

	while(top!=rear)
	{
		if(var[top+1].studentid==studentid)
		{

		}
		counter++;
	}
	printf("\n\n");
	printf("Data Entered Successfully Updated!!!\n\n");
	getch();
}

void deleteStudentRecord()
{
	char studentid[8];
	int counter=0;

	clrscr();
	printf("\n\nDELETE STUDENT RECORD MODULE\n\n");
	printf("Student ID: ");
	gets(studentid);

	while(top!=rear)
	{
		if(var[top+1].studentid==studentid)
		{

		}
		else
		{

		}
		counter++;
	}
	printf("\n\n");
	printf("Data Successfully Deleted!!!\n\n");
	getch();
}

void print()
{
	int x;

	clrscr();
	for(x=0; x<length; x++)
	{
		printf("\nStudent ID: ");
		puts(var[x].studentid);
		printf("\nLastname: ");
		puts(var[x].lastname);
		printf("\nFirstname: ");
		puts(var[x].firstname);
		printf("\nMiddlename: ");
		puts(var[x].middlename);
		printf("\nGender: ");
		puts(var[x].gender);
		printf("\nBirthdate: ");
		puts(var[x].birthdate);
		printf("\nAge: ");
		puts(var[x].age);
		printf("\nContact Number: ");
		puts(var[x].contactno);
		printf("\nGuardian: ");
		puts(var[x].guardian);
		printf("\nAddress: ");
		puts(var[x].address);
		printf("\n\n");
	}
	getch();
}

int searchID(char id[])
{
	int pointer=0,loc=-1;

	if (pointer<(top+1))
	{
		do
		{
			//strcmp(buf2, buf1)
			if (strcmp(id,var[pointer].studentid)==0)
			{
				loc=pointer;
				pointer=length-1;
			}
			else
			{
				loc=-1;
			}
			pointer++;
		}while(pointer<(top+1));
	}
	else
	{
		loc=-1;
	}
	return loc;
}

void searchStudentRecord()
{
	char studentid[8];
	int pointer=0;

	clrscr();

	printf("\n\nSEARCH STUDENT RECORD MODULE\n\n");
	printf("Student ID: ");
	gets(studentid);

	pointer=searchID(studentid);

	if (pointer==1)
	{
		printf("\nStudent ID: %s",var[pointer].studentid);
		printf("\nLastname: %s",var[pointer].lastname);
		printf("\nFirstname: %s",var[pointer].firstname);
		printf("\nMiddlename: %s",var[pointer].middlename);
		printf("\nGender: %s",var[pointer].gender);
		printf("\nBirthdate: %s",var[pointer].birthdate);
		printf("\nAge: %s",var[pointer].age);
		printf("\nContact Number: %s",var[pointer].contactno);
		printf("\nGuardian: %s",var[pointer].guardian);
		printf("\nAddress: %s",var[pointer].address);
		printf("\n\n");
	}
	else
	{
	    printf("Record not found!\n");
	}
	getch();
}

void displayAllRecords()
{
	int x;
	clrscr();

	printf("\n\nDISPLAY ALL RECORDS MODULE\n\n");

	for(x=0; x<top+1; x++)
	{
		printf("\nStudent ID: %s",var[x].studentid);
		printf("\nLastname: %s",var[x].lastname);
		printf("\nFirstname: %s",var[x].firstname);
		printf("\nMiddlename: %s",var[x].middlename);
		printf("\nGender: %s",var[x].gender);
		printf("\nBirthdate: %s",var[x].birthdate);
		printf("\nAge: %s",var[x].age);
		printf("\nContact Number: %s",var[x].contactno);
		printf("\nGuardian: %s",var[x].guardian);
		printf("\nAddress: %s",var[x].address);
		printf("\n\n");
	}
	getch();
}

void main1()
{
	char ans;
	int position=0;

	clrscr();

	if(position<top)
	{
		do
		{
			printf("\nStudent ID: %s",var[position].studentid);
			printf("\nLastname: %s",var[position].lastname);
			printf("\nFirstname: %s",var[position].firstname);
			printf("\nMiddlename: %s",var[position].middlename);
			printf("\nGender: %s",var[position].gender);
			printf("\nBirthdate: %s",var[position].birthdate);
			printf("\nAge: %s",var[position].age);
			printf("\nContact Number: %s",var[position].contactno);
			printf("\nGuardian: %s",var[position].guardian);
			printf("\nAddress: %s",var[position].address);
			printf("\n\n");

			printf("Press <1> Next Record!\n");
			printf("Press <2> Previous Record!\n");
			printf("Press X to exit!\n\n ");
			ans=getche();

			if(ans=='2')
			{
				if(position<top)
				{
					position++;
				}
				else
				{
				printf("End of file!\n\n");
				}
			}
			if(ans=='1')
			{
				if(position<top)
				{
					position--;
				}
				else
				{
					printf("End of file!\n\n");
				}
			}
		}while(ans=='1' || ans=='2');
	}
}

void printStudentRecord()
{
	int x;

	clrscr();
	printf("\n\nPRINT STUDENT RECORD MODULE\n\n");

	for(x=0; x<top+1; x++)
	{
		printf("\nStudent ID: %s",var[x].studentid);
		printf("\nLastname: %s",var[x].lastname);
		printf("\nFirstname: %s",var[x].firstname);
		printf("\nMiddlename: %s",var[x].middlename);
		printf("\nGender: %s",var[x].gender);
		printf("\nBirthdate: %s",var[x].birthdate);
		printf("\nAge: %s",var[x].age);
		printf("\nContact Number: %s",var[x].contactno);
		printf("\nGuardian: %s",var[x].guardian);
		printf("\nAddress: %s",var[x].address);
		printf("\n\n");
	}
	getch();
}

void lines()
{
	printf("\n\n\t\t\t--------------------------");
}

void main()
{
	char choice;
	int x,y;

	for(x=0; x<length; x++)
	{
		for(y=0; y<8; y++)
		{
			var[x].studentid[y]='\0';
		}
		for(y=0; y<15; y++)
		{
			var[x].lastname[y]='\0';
			var[x].firstname[y]='\0';
			var[x].middlename[y]='\0';
			var[x].birthdate[y]='\0';
			var[x].contactno[y]='\0';
		}
		for(y=0; y<6; y++)
		{
			var[x].gender[y]='\0';
		}
		for(y=0; y<3; y++)
		{
			var[x].age[y]='\0';
		}
		for(y=0; y<30; y++)
		{
			var[x].guardian[y]='\0';
		}
		for(y=0; y<120; y++)
		{
			var[x].address[y]='\0';
		}
	}


	for(;;)
	{
		textbackground(MAGENTA);
		textcolor(YELLOW);
		clrscr();
		lines();
		printf("\n\n\t\t\t  STATIC RECORD HANDLING");
		lines();
		printf("\n\n\t\t\t(1.) Add Record\n");
		printf("\n\t\t\t(2.) Update Record\n");
		printf("\n\t\t\t(3.) Delete Record\n");
		printf("\n\t\t\t(4.) Search Record\n");
		printf("\n\t\t\t(5.) Display Record\n");
		printf("\n\t\t\t(6.) Print Record\n");
		printf("\n\t\t\t(7.) Exit/Quit\n");
		printf("\n\n\n\t\t\t Press <1-7> Transactions!\n\n");
		printf("\n\n\n\t\t\tProgrammed by:\n");
		printf("\n\n\t\t\t\tRichard B. Juevesano\n");
		printf("\n\t\t\t\tBSIT-1\n");
		choice=getche();

		switch(choice)
		{
			case '1':
				addStudentRecord();
				break;
			case '2':
				updateStudentRecord();
				break;
			case '3':
				deleteStudentRecord();
				break;
			case '4':
				searchStudentRecord();
				break;
			case '5':
				displayAllRecords();
				break;
			case '6':
				printStudentRecord();
				break;
			case '7':
				exit(0);
				break;
		}
	}

}
/*_________________________END_______________________________________*/

Dude, you've already been told about code tags and where to use them, AND where to find info about them on the forum. I cant help you if I cant read your code... i.e the messy brackets in your nested loops because of the lack of code tagging

how???? can you give an example of code tagging???
i don't understand!!!!

[code] //code goes here [/code]
(akin to an HTML tag but with [] instead)
or you can highlight your code in the editing box and click on the

icon in the toolbar.

Look at the writing on the background of the Quick Reply box. It's also in the documentation when you first sign up. There's a large bold blue announcement about it in every forum. When you received the notification the first time from the moderator there was documentation in the PM as to how to do it. I had sent you a PM as a courtesy about it.

It's crucial but especially so when you are posting large code samples to have the formatting intact (posting it as plain text strips all the leading spaces and makes a mess).[code]
icon in the toolbar.

Look at the writing on the background of the Quick Reply box. It's also in the documentation when you first sign up. There's a large bold blue announcement about it in every forum. When you received the notification the first time from the moderator there was documentation in the PM as to how to do it. I had sent you a PM as a courtesy about it.

It's crucial but especially so when you are posting large code samples to have the formatting intact (posting it as plain text strips all the leading spaces and makes a mess).

i don't yet wat's dat....

I don't know how much clearer any of us can make it for you. Go up to the blue background of the code and click on "Help With Code Tags" or click on the dark blue bold announcement on the C++ forum page.

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.