Click here to Skip to main content
14,334,458 members

C / C++ / MFC

 
GeneralRe: Determining length of Switch compare Pin
leon de boer28-Sep-19 14:57
memberleon de boer28-Sep-19 14:57 
QuestionC++ string assignment to struct Pin
Fotsing18-Sep-19 11:54
memberFotsing18-Sep-19 11:54 
AnswerRe: C++ string assignment to struct Pin
Richard MacCutchan18-Sep-19 20:26
protectorRichard MacCutchan18-Sep-19 20:26 
GeneralRe: C++ string assignment to struct Pin
Fotsing18-Sep-19 22:33
memberFotsing18-Sep-19 22:33 
GeneralRe: C++ string assignment to struct Pin
Stefan_Lang19-Sep-19 2:12
memberStefan_Lang19-Sep-19 2:12 
GeneralRe: C++ string assignment to struct Pin
Fotsing19-Sep-19 13:06
memberFotsing19-Sep-19 13:06 
AnswerRe: C++ string assignment to struct Pin
Victor Nijegorodov18-Sep-19 20:30
memberVictor Nijegorodov18-Sep-19 20:30 
GeneralRe: C++ string assignment to struct Pin
Fotsing18-Sep-19 22:28
memberFotsing18-Sep-19 22:28 
no it is not a pseudo code am trying to write a program that can register a contact, delete or update the contact. so when i compile the is an error message "invalid array assignment" within the the delete function which is the code i posted before. the complete code is
  <pre>#include<iostream>
#include<conio.h>
#include<string.h>
#include<fstream>

using namespace std;
enum type{ home,work,fax,mobile,other };
struct contact{
	char num[15];
	char name[20];
	char TphoneN[6];
}phone[5];
const int max=5;
int index=0;

//reading function
bool reading(){
	char v;
	if(index<=5){
		cout<<"please enter phone number: ";
		gets(phone[index].num);
	
		cout<<"please enter the name: ";
		gets(phone[index].name);
	
		cout<<"the type of number( fax,  mobile,  home,  work,  other): ";
		gets(phone[index].TphoneN);
		/*cin>>v;
		switch(v){
			case 'f': phone[index].TphoneN='fax';
				break;
			case 'm': phone[index].TphoneN='mobile';
				break;
			case 'h': phone[index].TphoneN='home';
				break;
			case 'w': phone[index].TphoneN='work';
				break;
			case 'o': phone[index].TphoneN='other';
				break;
			default: cout<<"please enter a valid key: ";
		}*/
		index++;
		
		return true;
	}
	else 
		return false;
			
	}

//deleting function
bool delet(){
	int flag=0;
	cout<<"please enter the name of the person u wanna delete: ";
	char del[20];
	cin.getline(del,20);
	for(int i=0; i<=index; ++i){
		if(phone[i].name==del){
			for(int j=i; j<=index; ++j){
			
				phone[j].num=phone[j+1].num;
				phone[j].TphoneN=phone[j+1].TphoneN;
				phone[j].name=phone[j+1].name;
		 }
		 flag=1;
		}
}
	
	if(!flag){
		return false;
	}
	else{
			index--;
		return true;
	}
}

//function displqying all contacts
void all(){
	for(int i=0; i<=index; ++i){
		cout<<phone[i].name<<"\t"<<phone[i].num<<"\t"<<phone[i].TphoneN<<endl;
		cout<<"\n";
	}
}

//main function
int main(){
	int x;
	while(!0){
		cout<<"****"<<index<<"contact entries **** \n";
		cout<<"0 end \n1 new contact \n2 delete contact \n3 all contact \n4 empty contact memory";
		cin>>x;
		switch(x){
			case 1:
				bool y=reading();
				if(y==true){
					cout<<"contact successfuly saved";
				}
				else
					cout<<"an error accure could not save your contact";
			break;
			case 2:
			bool y=delet();
				if(y==true){
				cout<<"contact successfuly deleted";
			}
			else
				cout<<"sorry your name does not exist";
			break;
			case 3:
				all();
				break;
			case 4:
				cout<<"still searching";
				break;
			default:
				cout<<"sorry invalid key";
				break;
		}
	}
}




AnswerRe: C++ string assignment to struct Pin
CPallini18-Sep-19 21:01
mveCPallini18-Sep-19 21:01 
QuestionMFC VC++ Pin
Member 1457555617-Sep-19 20:42
memberMember 1457555617-Sep-19 20:42 
AnswerRe: MFC VC++ Pin
Victor Nijegorodov17-Sep-19 20:59
memberVictor Nijegorodov17-Sep-19 20:59 
GeneralRe: MFC VC++ Pin
Member 1457555617-Sep-19 21:06
memberMember 1457555617-Sep-19 21:06 
GeneralRe: MFC VC++ Pin
Victor Nijegorodov17-Sep-19 21:43
memberVictor Nijegorodov17-Sep-19 21:43 
GeneralRe: MFC VC++ Pin
Member 1457555617-Sep-19 23:35
memberMember 1457555617-Sep-19 23:35 
GeneralRe: MFC VC++ Pin
Victor Nijegorodov18-Sep-19 0:24
memberVictor Nijegorodov18-Sep-19 0:24 
AnswerRe: MFC VC++ Pin
CPallini17-Sep-19 21:12
mveCPallini17-Sep-19 21:12 
GeneralRe: MFC VC++ Pin
Member 1457555617-Sep-19 21:22
memberMember 1457555617-Sep-19 21:22 
GeneralRe: MFC VC++ Pin
Victor Nijegorodov17-Sep-19 21:39
memberVictor Nijegorodov17-Sep-19 21:39 
GeneralRe: MFC VC++ Pin
CPallini17-Sep-19 21:55
mveCPallini17-Sep-19 21:55 
GeneralRe: MFC VC++ Pin
Member 1457555617-Sep-19 23:49
memberMember 1457555617-Sep-19 23:49 
GeneralRe: MFC VC++ Pin
CPallini18-Sep-19 0:39
mveCPallini18-Sep-19 0:39 
AnswerRe: MFC VC++ Pin
Victor Nijegorodov17-Sep-19 21:47
memberVictor Nijegorodov17-Sep-19 21:47 
GeneralRe: MFC VC++ Pin
Stefan_Lang17-Sep-19 22:40
memberStefan_Lang17-Sep-19 22:40 
QuestionUnresolved extern "dwTlsIndex" exported function in dll Pin
ForNow17-Sep-19 2:41
memberForNow17-Sep-19 2:41 
AnswerRe: Unresolved extern "dwTlsIndex" exported function in dll Pin
CPallini17-Sep-19 3:19
mveCPallini17-Sep-19 3:19 

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.