Click here to Skip to main content
15,861,168 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: please explain this lines of code Pin
Richard MacCutchan2-Aug-18 21:47
mveRichard MacCutchan2-Aug-18 21:47 
AnswerRe: please explain this lines of code Pin
Jochen Arndt2-Aug-18 22:29
professionalJochen Arndt2-Aug-18 22:29 
NewsC++/CLI support comes to ReSharper C++ Pin
John Schroedl23-Jul-18 6:22
professionalJohn Schroedl23-Jul-18 6:22 
QuestionTo find the angle of turn in a car racing game in C++/SFML Pin
Tarun Jha21-Jul-18 23:39
Tarun Jha21-Jul-18 23:39 
AnswerRe: To find the angle of turn in a car racing game in C++/SFML Pin
John Schroedl23-Jul-18 6:41
professionalJohn Schroedl23-Jul-18 6:41 
GeneralRe: To find the angle of turn in a car racing game in C++/SFML Pin
Tarun Jha25-Jul-18 7:36
Tarun Jha25-Jul-18 7:36 
QuestionSmall RAII-like cleanup class in C++/CLI Pin
John Schroedl15-Jun-18 9:08
professionalJohn Schroedl15-Jun-18 9:08 
QuestionInformation Edit Source code for c++ Pin
Member 1165875229-May-18 19:48
Member 1165875229-May-18 19:48 
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



C++
<pre>//initializing the header files
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>

//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 Second Name\n");
			fflush(stdin);
			scanf("%s",addressbk.sname);
			

			printf("Enter E-mail address\n");
			fflush(stdin);
			scanf("%s",addressbk.emailadd);
			
			printf("Enter address\n");
			fflush(stdin);
			scanf("%s",addressbk.address);
			

			printf("Enter mobile\n");
			fflush(stdin);
			scanf("%s",addressbk.mobile);
			
			

			printf("Enter Code Melli no\n");
			fflush(stdin);
			scanf("%s",addressbk.codemelli);
			

			printf("Enter Phone Number no\n");
			fflush(stdin);
			scanf("%s",addressbk.phone);
			
			//printing all the entries to the main file (Records.txt)
			fprintf(Records,"%s %s %s %s %s %s %s \n",addressbk.name,addressbk.sname,addressbk.emailadd,addressbk.address,addressbk.mobile,addressbk.codemelli,addressbk.phone);

			fflush(stdin);
			//closure of the records file.
			fclose(Records);
		
		
			
		//initializing the choice character to give on optin to continue
			printf("WOULD LIKE TO CONTINUE? Y/N \n");
			scanf("%c",&choice2);
			fflush(stdin);


		if (choice2=='n'||choice2=='N')
		{
			system("cls");
			main();

		}
	}while(choice2=='y'||choice2=='Y');





}
/****************************************************************************************************************/
//the view function
void view()
{
char choice3;
//opening the Records file
		Records = fopen("Records.txt","a+");
		do
		{
			fgets(info,SIZE,Records);
			printf("%s\n",info);

		}while(!feof(Records));
			fclose(Records);
			system("pause");
			printf("Search for records??(Y/N)\n");
			scanf("%c",&choice3);
			fflush(stdin);
			if (toupper(choice3)=='Y')
			{
			search();
		}
		else if(toupper(choice3)=='N')
		{
			fclose(Records);
			system("pause");
			system("cls");
			main();
		}

		else
		{
			fclose(Records);
			system("cls");
		}
}
/********************************************************************************************/
//the main menu/welcome function
void welcome_note()
{

	//this statement displays the system time and date
		printf("\t\t              Phone BOOK V:1 \n\n\n");
		printf("\t\t           ProGrammeR: Fatemeh \n\n\n");
		printf("\t\t ----------------------------------------\n");
		printf("\t\t -	CHOOSE ONE BETWEEN (1-5)	-\n");
		printf("\t\t ----------------------------------------\n");

		printf("\t\t -	1	: VIEW RECORDS		-\n\n");

		printf("\t\t -	2	: MAKE NEW ENTRIES	-\n\n");

		printf("\t\t -	3	: SEARCH RECORDS  	-\n\n");

		printf("\t\t -	4	: DELETE RECORDS	-\n\n");

		printf("\t\t -	5	: EXIT			-\n\n");

		printf("\t\t ----------------------------------------\n");


}
/***********************************************************************************************/
//the search funtion
void search()
{

	//declaring the target variable Target
    char Target[SIZE];
	//
	int Found=0;
	if((Records=fopen("Records.txt","r"))==NULL)

		printf("Recordi Peyda Nashod!!!\n\n");
	else
	{
		system("cls");
		printf("\n\n");
		printf("\t----------------- SEARCH --------------");
		printf("\n\n");
		printf("\tEnter Code Melli to search:");
		fflush(stdin);
		scanf("%s",Target);
		while(!feof(Records)&& Found==0)
		{
			fscanf(Records,"%s %s %s %s %s %s %s",addressbk.name,addressbk.sname,addressbk.emailadd,addressbk.address,addressbk.mobile,addressbk.codemelli,addressbk.phone);
			if(strcmp(Target,addressbk.codemelli)==0)
			Found=1;
		}
		if(Found)
		{
			printf(".......Record Peyda Shod\n");
			system("pause");
			system("cls");
			printf("1 FILE FOUND : \n\n\n");
			printf("First Name: %s\n",addressbk.name);
			printf("Last Name: %s\n",addressbk.sname);
			printf("E-mail: %s\n",addressbk.emailadd);
			printf("Address : %s\n",addressbk.address);
			printf("mobile: %s\n",addressbk.mobile);
			printf("Code Melli: %s\n",addressbk.codemelli);
			printf("Phone Number: %s\n",addressbk.phone);
			system("pause");
		main();
		}
		else if(!Found)
		{
			printf("Motasfim Recordi Peyda Nashod\n");
			system("pause");
			main();
		}
		fclose(Records);
}
}
/***************************************************************************************************/
	void del_rec()
{
    char Target[SIZE];
	int Found=0;
		system("cls");
	rectemp=fopen("rectemp.txt","w");
	if((Records=fopen("Records.txt","r"))==NULL)
		printf("RECORDI YAFT NASHOD!!!\n\n");

	else{
		printf("\n\n");
		printf("\t--------------- DELETE ----------------");
		printf("\n\n");
		printf("\tEnter Code Melli to Delete: ");
		fflush(stdin);
		gets(Target);
		while(!feof(Records))
			{
			fscanf(Records,"%s %s %s %s %s %s %s ",addressbk.name,addressbk.sname,addressbk.emailadd,addressbk.address,addressbk.mobile,addressbk.codemelli,addressbk.phone);
			if(feof(Records))
				break;
			if(strcmp(Target,addressbk.codemelli)!=0)
				fprintf(rectemp,"%s %s %s %s %s %s %s \n",addressbk.name,addressbk.sname,addressbk.emailadd,addressbk.address,addressbk.mobile,addressbk.codemelli,addressbk.phone);
			else {
				Found=1;
				printf(".......Record Peyda Shod \n");
				system("pause");
				printf("First Name:%s\n",addressbk.name);
				printf("Last Name:%s\n",addressbk.sname);
				printf("E-mail:%s\n",addressbk.emailadd);
				printf("Address : %s\n",addressbk.address);
				printf("mobile: %s\n",addressbk.mobile);
				printf("Code Melli: %s\n",addressbk.codemelli);
				printf("Phone Number: %s\n",addressbk.phone);
				fflush(stdin);
				system("pause");
				}
			}
			if (!Found)
			{
			printf("\tRECORD NOT FOUND\n");//incase no files are located
			}
		printf("\tRECORD DELETED!!\n");

		fclose(Records);
		fclose(rectemp);
		remove("Records.txt");
		rename("rectemp.txt","Records.txt");
	main();	}

	}



AnswerRe: Information Edit Source code for c++ Pin
Richard MacCutchan29-May-18 21:05
mveRichard MacCutchan29-May-18 21:05 
AnswerRe: Information Edit Source code for c++ Pin
Jochen Arndt30-May-18 2:55
professionalJochen Arndt30-May-18 2:55 
QuestionError On a Project I'm Working On. (Sorry If Not descriptive enough, 1st time) Pin
CyberFaggot9-May-18 15:53
CyberFaggot9-May-18 15:53 
AnswerRe: Error On a Project I'm Working On. (Sorry If Not descriptive enough, 1st time) Pin
Richard MacCutchan11-May-18 21:19
mveRichard MacCutchan11-May-18 21:19 
QuestionPrint causes in afxtls.cpp Pin
Erich Ruth19-Apr-18 5:37
Erich Ruth19-Apr-18 5:37 
AnswerRe: Print causes in afxtls.cpp Pin
Richard Andrew x6413-May-18 7:22
professionalRichard Andrew x6413-May-18 7:22 
QuestionWhat is the alternative of _kbhit_ in linux ? Pin
Tarun Jha16-Apr-18 4:04
Tarun Jha16-Apr-18 4:04 
AnswerRe: What is the alternative of _kbhit_ in linux ? Pin
Maria Okta25-Jul-18 19:23
professionalMaria Okta25-Jul-18 19:23 
QuestionMore Than One Operator "+" Matches These Operands Pin
Paramu197313-Apr-18 5:26
Paramu197313-Apr-18 5:26 
QuestionRe: More Than One Operator "+" Matches These Operands Pin
Richard MacCutchan13-Apr-18 5:51
mveRichard MacCutchan13-Apr-18 5:51 
AnswerRe: More Than One Operator "+" Matches These Operands Pin
Paramu197313-Apr-18 6:05
Paramu197313-Apr-18 6:05 
GeneralRe: More Than One Operator "+" Matches These Operands Pin
Richard MacCutchan13-Apr-18 6:40
mveRichard MacCutchan13-Apr-18 6:40 
GeneralRe: More Than One Operator "+" Matches These Operands Pin
Paramu197313-Apr-18 14:18
Paramu197313-Apr-18 14:18 
QuestionHow to access the ref class declared DataTable ? Pin
Paramu197311-Apr-18 21:10
Paramu197311-Apr-18 21:10 
SuggestionRe: How to access the ref class declared DataTable ? Pin
Richard MacCutchan11-Apr-18 22:53
mveRichard MacCutchan11-Apr-18 22:53 
GeneralRe: How to access the ref class declared DataTable ? Pin
Paramu197312-Apr-18 1:42
Paramu197312-Apr-18 1:42 
GeneralRe: How to access the ref class declared DataTable ? Pin
Richard MacCutchan12-Apr-18 2:26
mveRichard MacCutchan12-Apr-18 2:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.