473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Directory Structure

Hi to everybody.. I need a help need to have a program to represent
directory structure(a directory can contain any number of directory or
files) alos write a programme to insert one element nd find one element
in structure. If anyone can do this program than pls mail me.
PLSSSSSSSSSS

Jan 17 '06 #1
10 2062
Ico
ma********@gmail.com wrote:
Hi to everybody.. I need a help need to have a program to represent
directory structure(a directory can contain any number of directory or
files) alos write a programme to insert one element nd find one element
in structure. If anyone can do this program than pls mail me.


I am very sorry, but your teacher prohibited us to do your homework for you.
We *are* allowed to help you, though. Just get started, and if you get
stuck, show us what you have made so far, and we can help you solve the
problem.

Good luck,

Ico

--
:wq
^X^Cy^K^X^C^C^C^C
Jan 17 '06 #2
hi
i made it thru a site a little little but its not complete can u help
me pls

typedef struct {
char name[64];
char address[128];
int phone;
} directory;

directory dr_rec;
dr_rec.name;

i know its not right but pls help me

misha

Jan 17 '06 #3
Pls help me plsssssssss

Jan 17 '06 #4
Ico
ma********@gmail.com wrote:
Pls help me
Like I said, we are willing to help you, but don't expect us to just do
your work. I asked you to show us what you got so far, but from what you
posted I concluded that you have not given it a serious try at all.

Find yourself a proper textbook, start at page 1 and work your way
through, that's the only advice I can give you at this point. As soon as
you have a program to show us ( having a main() would be a good start),
try again.
plsssssssss


You seem to be leaking.


--
:wq
^X^Cy^K^X^C^C^C^C
Jan 17 '06 #5
ok i did this can u tell whether it is right or not

reply me

#include <iostream.h>
#include <fstream.h>
//#include <process.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h >
#include <conio.h>
#include <dos.h>

//#include "c:\proj\neha.cpp"
//************************************************** ********



*********************************************
// CLASS NAME : MENU
// DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS
//************************************************** ********

class menu
{
public :
void main_menu(void) ;
void startup(void) ;
// void box(void) ;
// void line_hor (int, int, int, char) ;
// void line_ver (int, int, int, char) ;
} ;
//************************************************** ********
// CLASS NAME : DIARY
// DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS
// RELATED TO DIARY
//************************************************** ********

class diary
{
public :
diary(void) ;
~diary(void) ;
void add(void) ;
void modify(void) ;
void deletion(void) ;
void display_list(void) ;
private :
void sort(void) ;
void display_record(int) ;
int found_record(int) ;
void delete_record(int) ;
void modify_record(int) ;
int recordno(int) ;
int last_code(void) ;

int code ;
char name[20],phone1[10], phone2[10],
phone3[10], phone4[10], address[45] ;

} ;
//************************************************** ********
// CLASS NAME : MENU
// FUNCTION NAME : LINE_HOR
// DETAILS : IT ACCEPTS THE ROWS AND COLUMNS AND
// DRAW THE HORIZONTAL LINE
//************************************************** ********

//void menu :: line_hor(int column1, int column2, int row, char c)
//{
// for ( column1; column1<=column2; column1++ )
// {
//gotoxy(column1,row) ;
// cout <<c ;
// }
//
//************************************************** ********
// CLASS NAME : MENU
// FUNCTION NAME : LINE_VER
// DETAILS : IT ACCEPTS THE ROWS AND COLUMNS AND
// DRAW THE VERTICAL LINE
//************************************************** ********

//void menu :: line_ver(int row1, int row2, int column, char c)
//{
// for ( row1; row1<=row2; row1++ )
// {
//gotoxy(column,row1) ;
// cout <<c ;
// }
//}
//************************************************** ********
// CLASS NAME : MENU
// FUNCTION NAME : STARTUP
// DETAILS : IT CREATS THE STARTING SCREEN
//************************************************** ********

void menu :: startup(void)
{
clrscr();
}
//************************************************** **********
// CLASS NAME : MENU
// FUNCTION NAME : BOX
// DETAILS : IT CREATS BOX FOR THE MENU
//************************************************** ********

//void menu :: box(void)
//{
// line_hor(2,39,1,219) ;
// line_hor(2,39,24,219) ;
// line_ver(1,24,2,219) ;
// line_ver(1,24,39,219) ;
//}
//************************************************** ********
// CLASS NAME : MENU
// FUNCTION NAME : MAIN_MENU
// DETAILS : IT CREATS MENU AND CONTROL OTHER
// FUNCTIONS
//************************************************** ********

void menu :: main_menu(void)
{
char ch ;
while(1)
{
clrscr() ;
textmode(C40) ;
clrscr() ;
//box() ;
gotoxy(12,5) ;
cout <<"TELEPHONE DIARY" ;
gotoxy(12,6) ;
cout <<"---------------" ;
gotoxy(12,10) ;
cout <<"1: ADD RECORDS" ;
gotoxy(12,11) ;
cout <<"2: DISPLAY LIST" ;
gotoxy(12,12) ;
cout <<"3: DELETE RECORD" ;
gotoxy(12,13) ;
cout <<"4: MODIFY RECORD" ;
gotoxy(12,14) ;
cout <<"0: QUIT" ;
gotoxy(11,19) ;
cout <<"Enter your choice:" ;
ch = getch() ;
textmode(C80) ;
clrscr() ;
if (ch=='1')
{
diary d ;
d.add() ;
}
else if(ch=='2')
{
diary d ;
d.display_list() ;
}
else if(ch=='3')
{
diary d ;
d.deletion() ;
}
else if(ch=='4')
{
diary d ;
d.modify() ;
}
else if(ch=='0')
break ;
}
}
//************************************************** ********
// CLASS NAME : DIARY
// FUNCTION NAME : DIARY (CONSTRUCTOR)
// DETAILS : IT IS CONSTRUCTOR FUNCTION, GIVING
// DEFAULT VALUES
//************************************************** ********

diary :: diary(void)
{
code = 0 ;
name[0] = '\0' ;
phone1[0] = '\0' ;
phone2[0] = '\0' ;
phone3[0] = '\0' ;
phone4[0] = '\0' ;
address[0] = '\0' ;
}
//************************************************** ********
// CLASS NAME : DIARY
// FUNCTION NAME : ~DIARY (DISTRUCTOR)
// DETAILS : IT IS DESTRUCTOR FUNCTION
//************************************************** ********

diary :: ~diary(void)
{
}

//************************************************** ********
// CLASSNAME : DIARY
// FUNCTION NAME : DISPLAY_LIST
// DETAILS : IT DISPLAYS LIST OF THE PERSON'S
// RECORDS
//************************************************** ********

void diary :: display_list(void)
{
clrscr() ;
menu m ;
char t_name[20], t1_name[20] ;
gotoxy(3,5) ;
cout <<"Enter character(s) for selective list" ;
gotoxy(3,6) ;
cout <<"or press <ENTER> for whole list or `0' for exit : " ;
gets(t_name) ;
if (t_name[0] == '0')
return ;
int len = strlen(t_name) ;
clrscr() ;
fstream file ;
file.open("TDIARY.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int row = 4 ;
int found = 0 ;
int pageno = 1 ;
int flag = 1 ;
char ch ;
gotoxy(1,2) ;
cout <<" CODE NAME " ;
// m.line_hor(1,79,3,196) ;
// m.line_hor(1,79,24,196) ;
while (file.read((char *) this, sizeof(diary)))
{
flag = 1 ;
for (int i=0; i<len; i++)
t1_name[i] = name[i] ;
t1_name[len] = '\0' ;
if (strcmpi(t_name,t1_name)==0)
{
delay(20) ;
found = 1 ;
gotoxy(1,row) ;
cout <<code ;
gotoxy(7,row) ;
puts(name) ;
gotoxy(27,row) ;
cout <<"PHONE : " <<phone1 <<", " <<phone2
<<", "
<<phone3 <<", " <<phone4 ;
gotoxy(27,row+1) ;
cout <<"ADDRESS: " ;
puts(address) ;
if ( row == 22 )
{
flag = 0 ;
row = 4 ;
gotoxy(66,1) ;
cout <<"Page no. : " <<pageno ;
pageno++ ;
gotoxy(1,25) ;
cout <<"Press <ESC> to exit or any other
key to continue..." ;
ch = getch() ;
if (ch == 27)
return ;
clrscr() ;
gotoxy(1,2) ;
cout <<" CODE NAME " ;
// m.line_hor(1,79,3,196) ;
// m.line_hor(1,79,24,196) ;
}
else
row = row + 2 ;
}
}
if ( !found )
{
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,5) ;
cout <<"Records not found" ;
}
if (flag)
{
gotoxy(66,1) ;
cout <<"Page no. : " <<pageno ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
}
file.close() ;
}
//************************************************** ********
// CLASS NAME : DIARY
// FUNCTION NAME : DISPLAY_RECORD
// DETAILS : IT DISPLAYS SINGLE RECORD FOR THE
// GIVEN RECORD
//************************************************** ********

void diary :: display_record(int t_code)
{
fstream file ;
file.open("TDIARY.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(diary)))
{
if (t_code == code)
{
gotoxy(3,3) ;
cout <<"Code # " <<code ;
gotoxy(3,5) ;
cout <<"Name : " ;
puts(name) ;
gotoxy(3,6) ;
cout <<"Phone 1 : " <<phone1 ;
gotoxy(3,7) ;
cout <<"Phone 2 : " <<phone2 ;
gotoxy(3,8) ;
cout <<"Phone 3 : " <<phone3 ;
gotoxy(3,9) ;
cout <<"Phone 4 : " <<phone4 ;
gotoxy(3,10) ;
cout <<"Address : " ;
puts(address) ;
break ;
}
}
file.close() ;
}
//************************************************** ********
// CLASS NAME : DIARY
// FUNCTION NAME : LAST_CODE
// DETAILS : IT COUNTS THE RECORD IN THE FILE AND
// RETURN THE LAST CODE NO.
//************************************************** ********

int diary :: last_code()
{
fstream file ;
file.open("TDIARY.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int t=0 ;
while (file.read((char *) this, sizeof(diary)))
t++ ;
file.close() ;
return t ;
}
//************************************************** ********
// CLASS NAME : DIARY
// FUNCTION NAME : FOUND_RECORD
// DETAILS : IT RETURNS THAT RECORD IS FOUND FOR
// THE GIVEN CODE NO. OR NOT
//************************************************** ********

int diary :: found_record(int t_code)
{
fstream file ;
file.open("TDIARY.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int found=0 ;
while (file.read((char *) this, sizeof(diary)))
{
if (t_code == code)
{
found++ ;
break ;
}
}
file.close() ;
return found ;
}

//************************************************** ********
// CLASS NAME : DIARY
// FUNCTION NAME : ADD
// DETAILS : IT ADDS THE RECORDS IN THE DIARY'S
// FILE ( TDIARY.DAT)
//************************************************** ********

void diary :: add(void)
{
menu m ;
int valid, saved=0 ;
int t_code ;
t_code = last_code() ;
t_code++ ;
if (t_code == 1)
{
code = t_code ;
strcpy(name,"abc") ;
strcpy(phone1,"-") ;
strcpy(phone2,"-") ;
strcpy(phone3,"-") ;
strcpy(phone4,"-") ;
strcpy(address,"xyz") ;
fstream file ;
file.open("TDIARY.DAT ", ios::out | ios::app ) ;
file.write((char *) this, sizeof(diary)) ;
file.close() ;
//delete_record(t_code) ;
}
char ch ;
do
{
clrscr() ;
gotoxy(3,3) ;
cout <<"Code # " <<t_code ;
gotoxy(3,5) ;
cout <<"Name : " ;
gotoxy(3,6) ;
cout <<"Phone 1 : " ;
gotoxy(3,7) ;
cout <<"Phone 2 : " ;
gotoxy(3,8) ;
cout <<"Phone 3 : " ;
gotoxy(3,9) ;
cout <<"Phone 4 : " ;
gotoxy(3,10) ;
cout <<"Address : " ;
// m.line_hor(1,79,23,196) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER NAME OF THE PERSON" ;
gotoxy(13,5) ;
gets(name) ;
strupr(name) ;//converts it to upper case
if (strlen(name) > 19 || strlen(name) == 0)
{
valid = 0 ;
// sound(500) ;
//delay(100) ;
// nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"LENGTH SHOULD NOT BLANK OR
GREATER THAN 19" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,5) ; clreol() ;
}
} while ( !valid ) ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER THE PHONE NO. OF THE CUSTOMER,
<ENTER> FOR BLANK" ;
gotoxy(13,6) ;
gets(phone1) ;
if ((strlen(phone1) < 7 && strlen(phone1) > 0)
|| (strlen(phone1) > 9))
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"LENGTH SHOULD NOT GREATER THAN 9
OR LESS THAN 7" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,6) ; clreol() ;
}
} while ( !valid ) ;
if (strlen(phone1) == 0)
strcpy(phone1,"-") ;
do
{
valid = 1 ;
gotoxy(1,25) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER THE PHONE NO. OF THE CUSTOMER,
<ENTER> FOR BLANK" ;
gotoxy(13,7) ;
gets(phone2) ;
if ((strlen(phone2) < 7 && strlen(phone2) > 0)
|| (strlen(phone2) > 9))
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"LENGTH SHOULD NOT GREATER THAN 9
OR LESS THAN 7" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ;// clreol() ;
gotoxy(1,25) ; //clreol() ;
gotoxy(13,7) ; //clreol() ;
}
} while ( !valid ) ;
if (strlen(phone2) == 0)
strcpy(phone2,"-") ;
do
{
valid = 1 ;
gotoxy(1,25) ; //clreol() ;
gotoxy(3,25) ;
cout <<"ENTER THE PHONE NO. OF THE CUSTOMER,
<ENTER> FOR BLANK" ;
gotoxy(13,8) ;
gets(phone3) ;
if ((strlen(phone3) < 7 && strlen(phone3) > 0)
|| (strlen(phone3) > 9))
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,25) ; //clreol() ;
gotoxy(1,24) ;
cout <<"LENGTH SHOULD NOT GREATER THAN 9
OR LESS THAN 7" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; //clreol() ;
gotoxy(1,25) ; //clreol() ;
gotoxy(13,8) ; //clreol() ;
}
} while ( !valid ) ;
if (strlen(phone3) == 0)
strcpy(phone3,"-") ;
do
{
valid = 1 ;
gotoxy(1,25) ; //clreol() ;
gotoxy(3,25) ;
cout <<"ENTER THE PHONE NO. OF THE CUSTOMER,
<ENTER> FOR BLANK" ;
gotoxy(13,9) ;
gets(phone4) ;
if ((strlen(phone4) < 7 && strlen(phone4) > 0)
|| (strlen(phone4) > 9))
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"LENGTH SHOULD NOT GREATER THAN 9
OR LESS THAN 7" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; //clreol() ;
gotoxy(1,25) ; //clreol() ;
gotoxy(13,9) ; //clreol() ;
}
} while ( !valid ) ;
if (strlen(phone4) == 0)
strcpy(phone4,"-") ;
do
{
valid = 1 ;
gotoxy(1,25) ; //clreol() ;
gotoxy(3,25) ;
cout <<"ENTER ADDRESS OF THE PERSON" ;
gotoxy(13,10) ;
gets(address) ;
strupr(address) ;
if (strlen(address) > 43 || strlen(address) ==
0)
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"SHOULD NOT BLANK OR GREATER THAN
48" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,10) ; clreol() ;
}
} while ( !valid ) ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,23) ; clreol() ;
gotoxy(1,13) ;
cout <<"Do you want to save the record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(41,13) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(41,13) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'Y')
{
saved = 1 ;
code = t_code ;
fstream file ;
file.open("TDIARY.DAT", ios::out | ios::app ) ;
file.write((char *) this, sizeof(diary)) ;
file.close() ;
t_code++ ;
}
gotoxy(1,14) ;
cout <<"Do you want to add more records (y/n) : " ;
do
{
valid = 1 ;
gotoxy(41,14) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(41,14) ; clreol() ;
}
} while ( !valid ) ;
} while (ch == 'Y') ;
if (saved)
sort() ;
}

//************************************************** ********
// CLASS NAME : DIARY
// FUNCTION NAME : DELETE_RECORD
// DETAILS : IT DELETES THE RECORD IN THE DIARY'S
// FILE (TDIARY.DAT) FOR THE GIVEN CODE
//************************************************** ********

void diary :: delete_record(int t_code)
{
fstream file ;
file.open("TDIARY.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(diary)) ;
if ( file.eof() )
break ;
if ( code != t_code )
temp.write((char *) this, sizeof(diary)) ;
}
file.close() ;
temp.close() ;
file.open("TDIARY.DAT", ios::out) ;
temp.open("temp.dat ", ios::in) ;
temp.seekg(0,ios::beg) ;
t_code = 1 ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(diary)) ;
code = t_code ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(diary)) ;
t_code++ ;
}
file.close() ;
temp.close() ;
}

//************************************************** ********
// CLASS NAME : DIARY
// FUNCTION NAME : DELETION
// DETAILS : IT GIVES THE CODE NO. TO DELETE THE
// RECORD IN DIARY'S FILE (TDIARY.DAT)
//************************************************** ********

void diary :: deletion(void)
{
menu m ;
clrscr() ;
int valid ;
int t_code=0, t;
char t1_code[5], t2_code[5] ;
char ch ;
gotoxy(3,3) ;
cout <<"Enter Code no. of the record to be deleted " ;
gotoxy(3,4) ;
cout <<"or Press <ENTER> to see from the list or `0' to exit : "
;
gets(t1_code) ;
t = atoi(t1_code) ;
t_code = t ;
if (t1_code[0] == '0')
return ;
if (t1_code[0] != '\0')
{
clrscr() ;
if (!found_record(t_code))
{
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(3,15) ;
cout <<"Record not found" ;
// m.line_hor(1,79,24,196) ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(t_code) ;
gotoxy(3,12) ;
cout <<"Do you want to delete this Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(45,12) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(45,12) ; clreol() ;
}
} while (!valid ) ;
if (ch == 'N')
return ;
gotoxy(1,25) ;
cout <<"Wait..." ;
delete_record(t_code) ;
clrscr() ;
gotoxy(1,14) ;
cout <<"Record Deleted\n" ;
// m.line_hor(1,79,24,196) ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
return ;
}
display_list() ;
gotoxy(1,25) ;
clreol() ;
gotoxy(3,25) ;
cout <<"Enter Code no. of the record or <ENTER> to exit " ;
gets(t2_code) ;
t = atoi(t2_code) ;
t_code = t ;
if (t2_code[0] == '\0')
return ;
clrscr() ;
if (!found_record(t_code))
{
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(3,15) ;
cout <<"Record not found" ;
// m.line_hor(1,79,24,196) ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(t_code) ;
gotoxy(3,12) ;
cout <<"Do you want to delete this Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(45,12) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(45,12) ; clreol() ;
}
} while (!valid ) ;
if (ch == 'N')
return ;
gotoxy(1,25) ;
cout <<"Wait..." ;
delete_record(t_code) ;
clrscr() ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(3,14) ;
cout <<"Record Deleted" ;
// m.line_hor(1,79,24,196) ;
gotoxy(1,25) ;
cout <<"Press any key to continue...." ;
getch() ;
}
//************************************************** ********
// CLASS NAME : DIARY
// FUNCTION NAME : MODIFY_RECORD
// DETAILS : IT MODIFIES THE RECORD IN THE DIARY'S
// FILE (TDIARY.DAT) FOR THE GIVEN CODE
//************************************************** ********

void diary :: modify_record(int t_code)
{
menu m ;
int valid, modified=0 ;
char ch ;
// m.line_hor(1,79,12,196) ;
gotoxy(3,14) ;
cout <<"Code # " <<t_code ;
gotoxy(3,16) ;
cout <<"Name : " ;
gotoxy(3,17) ;
cout <<"Phone 1 : " ;
gotoxy(3,18) ;
cout <<"Phone 2 : " ;
gotoxy(3,19) ;
cout <<"Phone 3 : " ;
gotoxy(3,20) ;
cout <<"Phone 4 : " ;
gotoxy(3,21) ;
cout <<"Address : " ;
gotoxy(1,25) ; clreol() ;
// m.line_hor(1,79,23,196) ;
gotoxy(13,16) ;
cout <<"Change (y/n) : " ;
do
{
valid = 1 ;
gotoxy(28,16) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(28,16) ; clreol() ;
}
} while (!valid) ;
valid = 0 ;
while (!valid && ch == 'Y')
{
modified = 1 ;
valid = 1 ;
gotoxy(13,16) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER NAME OF THE PERSON" ;
gotoxy(13,16) ;
gets(name) ;
strupr(name) ;
if (strlen(name) > 19 || strlen(name) == 0)
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"LENGTH SHOULD NOT BLANK OR GREATER THAN
19" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,16) ; clreol() ;
}
}
gotoxy(1,25) ; clreol() ;
gotoxy(13,17) ;
cout <<"Change (y/n) : " ;
do
{
valid = 1 ;
gotoxy(28,17) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(28,17) ; clreol() ;
}
} while (!valid) ;
valid = 0 ;
while (!valid && ch == 'Y')
{
modified = 1 ;
valid = 1 ;
gotoxy(13,17) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER THE PHONE NO. OF THE CUSTOMER, <ENTER> FOR
BLANK" ;
gotoxy(13,17) ;
gets(phone1) ;
if ((strlen(phone1) < 7 && strlen(phone1) > 0) ||
(strlen(phone1) > 9))
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"LENGTH SHOULD NOT GREATER THAN 9 OR LESS
THAN 7" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,17) ; clreol() ;
}
if (strlen(phone1) == 0)
strcpy(phone1,"-") ;
}
gotoxy(1,25) ; clreol() ;
gotoxy(13,18) ;
cout <<"Change (y/n) : " ;
do
{
valid = 1 ;
gotoxy(28,18) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(28,18) ; clreol() ;
}
} while (!valid) ;
valid = 0 ;
while (!valid && ch == 'Y')
{
modified = 1 ;
valid = 1 ;
gotoxy(13,18) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER THE PHONE NO. OF THE CUSTOMER, <ENTER> FOR
BLANK" ;
gotoxy(13,18) ;
gets(phone2) ;
if ((strlen(phone2) < 7 && strlen(phone2) > 0) ||
(strlen(phone2) > 9))
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"LENGTH SHOULD NOT GREATER THAN 9 OR LESS
THAN 7" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,18) ; clreol() ;
}
if (strlen(phone2) == 0)
strcpy(phone2,"-") ;
}
gotoxy(1,25) ; clreol() ;
gotoxy(13,19) ;
cout <<"Change (y/n) : " ;
do
{
valid = 1 ;
gotoxy(28,19) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(28,19) ; clreol() ;
}
} while (!valid) ;
valid = 0 ;
while (!valid && ch == 'Y')
{
modified = 1 ;
valid = 1 ;
gotoxy(13,19) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER THE PHONE NO. OF THE CUSTOMER, <ENTER> FOR
BLANK" ;
gotoxy(13,19) ;
gets(phone3) ;
if ((strlen(phone3) < 7 && strlen(phone3) > 0) ||
(strlen(phone3) > 9))
{
valid = 0 ;
// sound(500) ;
delay(100) ;
//nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"LENGTH SHOULD NOT GREATER THAN 9 OR LESS
THAN 7" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,19) ; clreol() ;
}
if (strlen(phone3) == 0)
strcpy(phone3,"-") ;
}
gotoxy(1,25) ; clreol() ;
gotoxy(13,20) ;
cout <<"Change (y/n) : " ;
do
{
valid = 1 ;
gotoxy(28,20) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(28,20) ; clreol() ;
}
} while (!valid) ;
valid = 0 ;
while (!valid && ch == 'Y')
{
modified = 1 ;
valid = 1 ;
gotoxy(13,20) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER THE PHONE NO. OF THE CUSTOMER, <ENTER> FOR
BLANK" ;
gotoxy(13,20) ;
gets(phone4) ;
if ((strlen(phone4) < 7 && strlen(phone4) > 0) ||
(strlen(phone4) > 9))
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"LENGTH SHOULD NOT GREATER THAN 9 OR LESS
THAN 7" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,20) ; clreol() ;
}
if (strlen(phone4) == 0)
strcpy(phone4,"-") ;
}
gotoxy(1,25) ; clreol() ;
gotoxy(13,21) ;
cout <<"Change (y/n) : " ;
do
{
valid = 1 ;
gotoxy(28,21) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
//nosound() ;
gotoxy(28,21) ; clreol() ;
}
} while (!valid) ;
valid = 0 ;
while (!valid && ch == 'Y')
{
modified = 1 ;
valid = 1 ;
gotoxy(13,21) ; clreol() ;
gotoxy(3,25) ;
cout <<"ENTER ADDRESS OF THE PERSON" ;
gotoxy(13,21) ;
gets(address) ;
strupr(address) ;
if (strlen(address) > 43 || strlen(address) == 0)
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"SHOULD NOT BLANK OR GREATER THAN 48" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
gotoxy(1,24) ; clreol() ;
gotoxy(1,25) ; clreol() ;
gotoxy(13,21) ; clreol() ;
}
}
if (!modified)
return ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,23) ; clreol() ;
gotoxy(1,23) ;
cout <<"Do you want to save the record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(41,23) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(41,23) ; clreol() ;
}
} while ( !valid ) ;
if (ch == 'N')
return ;
fstream file ;
file.open("TDIARY.DAT", ios::out | ios::ate) ;
int recno ;
recno = t_code ;
int location ;
location = (recno-1) * sizeof(diary) ;
file.seekp(location) ;
file.write((char *) this, sizeof(diary)) ;
file.close() ;
sort() ;
clrscr() ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(1,14) ;
cout <<"Record Modified" ;
// m.line_hor(1,79,24,196) ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
}
//************************************************** ********
// CLASS NAME : DIARY
// FUNCTION NAME : MODIFY
// DETAILS : IT GIVES THE CODE NO. TO MODIFY THE
// RECORD IN DIARY'S FILE (TDIARY.DAT)
//************************************************** ********

void diary :: modify(void)
{
menu m ;
clrscr() ;
int valid ;
int t_code=0, t;
char t1_code[5], t2_code[5] ;
char ch ;
gotoxy(3,3) ;
cout <<"Enter Code no. of the record to be modify " ;
gotoxy(3,4) ;
cout <<"or Press <ENTER> to see from the list or `0' to exit : "
;
gets(t1_code) ;
t = atoi(t1_code) ;
t_code = t ;
if (t1_code[0] == '0')
return ;
if (t1_code[0] != '\0')
{
clrscr() ;
if (!found_record(t_code))
{
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(3,15) ;
cout <<"Record not found" ;
// m.line_hor(1,79,24,196) ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(t_code) ;
gotoxy(3,12) ;
cout <<"Do you want to modify this Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(45,12) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(45,12) ; clreol() ;
}
} while (!valid ) ;
if (ch == 'N')
return ;
modify_record(t_code) ;
return ;
}
display_list() ;
gotoxy(1,25) ;
clreol() ;
gotoxy(3,25) ;
cout <<"Enter Code no. of the record or <ENTER> to exit " ;
gets(t2_code) ;
t = atoi(t2_code) ;
t_code = t ;
if (t2_code[0] == '\0')
return ;
clrscr() ;
if (!found_record(t_code))
{
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(3,15) ;
cout <<"Record not found" ;
// m.line_hor(1,79,24,196) ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
return ;
}
display_record(t_code) ;
gotoxy(3,12) ;
cout <<"Do you want to modify this Record (y/n) : " ;
do
{
valid = 1 ;
gotoxy(45,12) ;
ch = getche() ;
ch = toupper(ch) ;
if (ch != 'Y' && ch != 'N')
{
valid = 0 ;
// sound(500) ;
delay(100) ;
// nosound() ;
gotoxy(45,12) ; clreol() ;
}
} while (!valid ) ;
if (ch == 'N')
return ;
modify_record(t_code) ;
}

//************************************************** ********
// CLASS NAME : DIARY
// FUNCTION NAME : SORT
// DETAILS : IT SORTS THE RECORD IN THE DIARY'S
// FILE (TDIARY.DAT)
//************************************************** ********

void diary :: sort(void)
{
int i=0,j ;
diary arr[100] ;
diary temp ;
fstream file ;
file.open("TDIARY.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) &arr[i], sizeof(diary)))
i++ ;
int size ;
size = i ;
file.close() ;
for (i=1; i<size; i++)
for (j=0; j<size-i; j++)
{
if (strcmp(arr[j].name,arr[j+1].name) > 0)
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
int t_code = 1 ;
for (i=0; i<size; i++)
{
arr[i].code = t_code ;
t_code++ ;
}
file.open("TDIARY.DAT", ios::out) ;
for (i=0; i<size; i++)
file.write((char *) &arr[i], sizeof(diary)) ;
file.close() ;
}


//************************************************** ********
// FUNCTION NAME : MAIN
// DETAILS : IT CALLS THE STARTUP FUNCTION AND
// MENU FUNCTION.
//************************************************** ********

void main(void)
{
menu m ;
m.startup() ;
m.main_menu() ;
}

Jan 18 '06 #6
ma********@gmail.com wrote:
ok i did this can u tell whether it is right or not

reply me

#include <iostream.h>


<snip lots of C++ code>

I don't need to go any further than this to tell you it is wrong.
Standard C does not have a header called iostream.h. If you want to talk
about C++ try in comp.lang.c++. They will probably tell you not to use
iostream.h as well, but for slightly different reasons.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Jan 18 '06 #7
ma********@gmail.com wrote:

leave some context in your posts. That is leave in what you are
replying to.
ok i did this can u tell whether it is right or not
post in english
reply me
don't make demands in this news group
#include <iostream.h>
don't post C++ code in comp.lang.c

<snip>
class diary
{
public :
diary(void) ;
~diary(void) ;
void add(void) ;
void modify(void) ;
void deletion(void) ;
void display_list(void) ;
private :
void sort(void) ;
void display_record(int) ;
int found_record(int) ;
void delete_record(int) ;
void modify_record(int) ;
int recordno(int) ;
int last_code(void) ;

int code ;
char name[20],phone1[10], phone2[10],
phone3[10], phone4[10], address[45] ;

} ;
your original assignment (see how it helps to leave some
context). Asked you to simulate a file directory structure.
This seems to be something completly different.

Are you still asking about the same assignment? Is this your code?

<snip>
void main(void)
int main (void)

so to answer your question, no it isn't right
--
Nick Keighley
****Can anyone find the error

Yes:
Error on line 0: Lazy programmer.
(comp.lang.c++)

Jan 18 '06 #8
<ma********@gmail.com> wrote:
ok i did this can u tell whether it is right or not

reply me

#include <iostream.h>
#include <fstream.h>
//#include <process.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h >
#include <conio.h>
#include <dos.h>

//#include "c:\proj\neha.cpp"
//************************************************** ********



*********************************************
// CLASS NAME : MENU
// DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS
//************************************************** ********

class menu
{
public :
void main_menu(void) ;
void startup(void) ;
// void box(void) ;
// void line_hor (int, int, int, char) ;
// void line_ver (int, int, int, char) ;
} ;


<snip>

I am sure you realize we have a big natural language problem here. Your
initial question seemed aimed at how to handle the file structure in a
computer operating system. What you have written ( or provided?) is what we
call in the USA, an address book. My guess is that you poked around and
found some C looking code and posted it as your work.

So, no, this is not correct if I understand what your assignment is.

Furthermore, what you have provided is written in a quite old version of C
and uses a great many include files which are not, and never were, a part of
"official" C. So even if this is your work and does comply with the
assignment it is fruitless to ask for help here.

Osmium's five step program.

1. get the question clear in your mind.
2. write pseudocode if the problem is sizeable or get a mental "image" of
the method of solution
3. wiite a little bit of code (10-20 lines for a novice)
4. test
5. go to 3

Note that there is no way to exit this program, at best it goes on probation
for extended periods of time.
Jan 18 '06 #9
ma********@gmail.com wrote:

ok i did this can u tell whether it is right or not

#include <iostream.h>
#include <fstream.h>
//#include <process.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h >
#include <conio.h>
#include <dos.h>


.... snip coded monstrosity ...

Whatever it is it is not C. There is no such thing as iostream.h,
fstream.h, conio.h, dos.h. And in many systems that are not C99
compliant // is a syntax error.

The word "you" is spelled "you". Do not use silly hard to read
abbreviations in usenet.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Jan 18 '06 #10
osmium wrote:
<ma********@gmail.com> wrote:
<snip>
class menu
{


<snip>
Furthermore, what you have provided is written in a quite old version of C
and uses a great many include files which are not, and never were, a part of
"official" C.


<snip>

No it isn't. It may or may not be written in an old version of C++, but
C++ is a different language with its own news group.

FYI, we do deal with "old" C here, even back as far as K&R C
occasionally, although people have to state that it is K&R rather than
ANSI/ISO C if that is what they want.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Jan 18 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: FISH | last post by:
Ever have one of those days when you're not sure if it's you who's gone mad, or the rest of the world? I have an Open Source project on SourceForge for communication with YSMG - Yahoo's IM...
2
by: Jignesh | last post by:
Can someone please tell me how to "import" a directory structure into a project in Microsoft Visual C++ .NET 2003. I have an extremeley complex directory structure consisting of thousands of...
1
by: soni29 | last post by:
when creating a project with namespace like: wrox.csharp.basics.overflowtest is it good practice to have the directory structure like that also: c:\wrox\csharp\basics\overflowtext.cs Also if it...
4
by: Elmo Watson | last post by:
Is there a way, with the System.IO class, to do a recursive list of a directory structure? For instance, in DirectoryInfo, you have GetDirectories and GetFiles .... In Directory, you have...
8
by: nick | last post by:
I have a problem and I've been using a cheezy work around and was wondering if anyone else out there has a better solution. The problem: Let's say I have a web application appA. Locally, I set...
6
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application...
6
by: dave | last post by:
I really have 2 questions regarding the following xml snippet. The xml is a directory representation. <?xml version="1.0" standalone="yes"?> <FileSystem> <Row> <ID>1</ID> <Name>Root</Name>...
3
by: _DS | last post by:
Problem with mapping a directory tree to a tree control: It takes a while to recurse subdirs and map them to nodes. This is solved in some books I've seen (MacDonald, Albahari) by reading the...
10
by: Alan Searle | last post by:
I would like to scan a directory structure into XML to offer navigation functionality in HTML / XSL pages. My questions are: 1. Which is the best structure to store variable depth heirarchies...
8
by: theCancerus | last post by:
Hi All, I am not sure if this is the right place to ask this question but i am very sure you may have faced this problem, i have already found some post related to this but not the answer i am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.