Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Information Edit Source code for c++

Information Edit Source code for c++

Scheduled Pinned Locked Moved Managed C++/CLI
c++design
3 Posts 3 Posters 11 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 11624369
    wrote on last edited by
    #1

    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
    
    L J 2 Replies Last reply
    0
    • U User 11624369

      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
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Sorry, this site does not provide code to order. Please edit your question and explain what does not work, and where in the code the problem lies. It would also help if you removed all the code that is not related to the problem.

      1 Reply Last reply
      0
      • U User 11624369

        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
        
        J Offline
        J Offline
        Jochen Arndt
        wrote on last edited by
        #3

        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 the record() 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 call main() too. To process the next operation you have to implement a loop in main() 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).

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups