Information Edit Source code for c++
-
Hello guys
I've have a c++ source code for a litle phoonbook.
It has the insert option, View and delete but i've can't edit a record!
Here is source code please add a edit part for this code as possible.
Also it does not going back to main menu after adding a record.thanks
//initializing the header files
#include
#include
#include
#include//defining the properties of the fields used in the program
#define NAMES 50
#define EMAIL 20
#define PHONE 20
#define ADDRESS 8
#define MOBILE 10
#define SIZE 500
//declaring the functions
void welcome_note();
void record();
void view();
void search();
void del_rec();
char info[SIZE];
//using stuctures that represent the fields in the program
struct addressbk
{
char name [NAMES] ;
char sname [NAMES] ;
char emailadd [EMAIL] ;
char address [ADDRESS];
char mobile [MOBILE];
char phone [PHONE];
char codemelli [PHONE];} addressbk;
//initializing the files used in the program
FILE *Records;
FILE *rectemp;
//initializing of the main function
/****************************************************************************************************/
void main()
{int choice=0; //using the system() statement to clear the screen system("cls"); //using the sysytem (color) to create a user interface system("color 17"); fflush(stdin); //initializing the welcome note welcome\_note(); printf("\\nEnter your Choice here \\t"); scanf("%i",&choice); fflush(stdin); //!!using the switch statement to give an option to initialize the functions switch (choice) { case 1: { system("cls"); view(); break; } case 2: { system("cls"); record(); break; } case 3: { system("cls"); search(); break; } case 4: { system("cls"); del\_rec(); break; } case 5: { system("cls"); break; } default: { printf("Please Only Choose Between NO. 1-5\\n"); system("pause"); system("cls"); main(); } }
}
/******************************************************************************************************/
//initializing the record function
void record()
{
char choice2;do { //opening the Records file Records = fopen("Records.txt","a+"); printf("Enter Name\\n"); fflush(stdin); scanf("%s",addressbk.name); printf("Enter Secon
-
Hello guys
I've have a c++ source code for a litle phoonbook.
It has the insert option, View and delete but i've can't edit a record!
Here is source code please add a edit part for this code as possible.
Also it does not going back to main menu after adding a record.thanks
//initializing the header files
#include
#include
#include
#include//defining the properties of the fields used in the program
#define NAMES 50
#define EMAIL 20
#define PHONE 20
#define ADDRESS 8
#define MOBILE 10
#define SIZE 500
//declaring the functions
void welcome_note();
void record();
void view();
void search();
void del_rec();
char info[SIZE];
//using stuctures that represent the fields in the program
struct addressbk
{
char name [NAMES] ;
char sname [NAMES] ;
char emailadd [EMAIL] ;
char address [ADDRESS];
char mobile [MOBILE];
char phone [PHONE];
char codemelli [PHONE];} addressbk;
//initializing the files used in the program
FILE *Records;
FILE *rectemp;
//initializing of the main function
/****************************************************************************************************/
void main()
{int choice=0; //using the system() statement to clear the screen system("cls"); //using the sysytem (color) to create a user interface system("color 17"); fflush(stdin); //initializing the welcome note welcome\_note(); printf("\\nEnter your Choice here \\t"); scanf("%i",&choice); fflush(stdin); //!!using the switch statement to give an option to initialize the functions switch (choice) { case 1: { system("cls"); view(); break; } case 2: { system("cls"); record(); break; } case 3: { system("cls"); search(); break; } case 4: { system("cls"); del\_rec(); break; } case 5: { system("cls"); break; } default: { printf("Please Only Choose Between NO. 1-5\\n"); system("pause"); system("cls"); main(); } }
}
/******************************************************************************************************/
//initializing the record function
void record()
{
char choice2;do { //opening the Records file Records = fopen("Records.txt","a+"); printf("Enter Name\\n"); fflush(stdin); scanf("%s",addressbk.name); printf("Enter Secon
-
Hello guys
I've have a c++ source code for a litle phoonbook.
It has the insert option, View and delete but i've can't edit a record!
Here is source code please add a edit part for this code as possible.
Also it does not going back to main menu after adding a record.thanks
//initializing the header files
#include
#include
#include
#include//defining the properties of the fields used in the program
#define NAMES 50
#define EMAIL 20
#define PHONE 20
#define ADDRESS 8
#define MOBILE 10
#define SIZE 500
//declaring the functions
void welcome_note();
void record();
void view();
void search();
void del_rec();
char info[SIZE];
//using stuctures that represent the fields in the program
struct addressbk
{
char name [NAMES] ;
char sname [NAMES] ;
char emailadd [EMAIL] ;
char address [ADDRESS];
char mobile [MOBILE];
char phone [PHONE];
char codemelli [PHONE];} addressbk;
//initializing the files used in the program
FILE *Records;
FILE *rectemp;
//initializing of the main function
/****************************************************************************************************/
void main()
{int choice=0; //using the system() statement to clear the screen system("cls"); //using the sysytem (color) to create a user interface system("color 17"); fflush(stdin); //initializing the welcome note welcome\_note(); printf("\\nEnter your Choice here \\t"); scanf("%i",&choice); fflush(stdin); //!!using the switch statement to give an option to initialize the functions switch (choice) { case 1: { system("cls"); view(); break; } case 2: { system("cls"); record(); break; } case 3: { system("cls"); search(); break; } case 4: { system("cls"); del\_rec(); break; } case 5: { system("cls"); break; } default: { printf("Please Only Choose Between NO. 1-5\\n"); system("pause"); system("cls"); main(); } }
}
/******************************************************************************************************/
//initializing the record function
void record()
{
char choice2;do { //opening the Records file Records = fopen("Records.txt","a+"); printf("Enter Name\\n"); fflush(stdin); scanf("%s",addressbk.name); printf("Enter Secon
I'm not going to write the complete edit function for you. But you already have most of the parts because editing can be implemented by selecting, reading, entering new data, deleting the old record, and inserting the edited data.
Quote:
Also it does not going back to main menu after adding a record.
Never call
main()
from within your code as done here in therecord()
function:if (choice2=='n'||choice2=='N')
{
system("cls");
main();
}Just return from the function (simply delete the above code block). Then execution continues after the function call in
main()
. Similar for the other functions where you callmain()
too. To process the next operation you have to implement a loop inmain()
that gets and processes the next choice until the exit option is selected:do
{
printf("\nEnter your Choice here \t");
scanf("%i",&choice);
fflush(stdin);
switch (choice)
{
// ...
}
system("cls");
} while (choice != 5);Note also that this the wrong forum because this is about Managed C++/CLI as stated in the topmost (sticky) post. Please use the C / C++ / MFC Discussion Boards[^] or Ask a Question for further C/C++ related questions where the latter is the better choice when posting larger amounts of code (which should be avoided).