kurd_programming
چهارشنبه 14 خرداد 1393, 11:40 صبح
سلام
بنده در حال نوشتن پروژه دفتر تلفن هستم که با استراکت نوشتم کدش رو قرار میدم تا ببنید :
#include "stdafx.h"
#include<iostream>
#include<string>
#include<conio.h>
using namespace std;
struct tellphone{
char fname[100],lname[100];
double no;
};
int main()
{
int a=0,i,j,count=0;
char ans;
int src;
tellphone tell[100];
cout<<"************* WELCOME TO TELLPHONE menu ************* "<<endl;
cout<<"Enter 1 for insert : "<<endl;
cout<<"Enter 2 for edit : "<<endl;
cout<<"Enter 3 for search : "<<endl;
cin>>a;
switch(a)
{
case 1:
for(i=0;;i++)
{
cout<<"************* WELCOME TO Insert ************* "<<endl;
cout<<"Enter a first name : "<<endl;
cin.getline(tell[i].fname,30);
cout<<"Enter a Family : "<<endl;
cin.getline(tell[i].lname,30);
cout<<"Enter a No. phone : ";
cin>>tell[i].no;
cout<<"************* INSERT IS COMPLETE ************* "<<endl;
//cout<<"Do you want go to menu ? Y/N .... ";
count++;
//cin>>ans;
}
case 2:
cout<<"************* WELCOME TO EDIT *************"<<endl;
cout<<"Enter a no phone for edit :"<<endl;
cin>>src;
for(i=0;i<count;i++)
{
if(src==tell[i].no)
{
cout<<"Name is : "<<tell[i].fname<<endl;
cout<<"family is : "<<tell[i].lname<<endl;
cout<<"No.phone is : "<<tell[i].no<<endl;
cout<<"Enter a name for edit : "<<endl;
cin.getline(tell[i].fname,20);
cout<<"Enter a FAmily for edit : "<<endl;
cin.getline(tell[i].lname,20);
cout<<"Enter a no.phone for edit : "<<endl;
cin>>tell[i].no;
cout<<"*************EDIT it complete*************";
}else
{
cout<<"No not found :(";
}
}
//break;
case 3:
cout<<"************* WELCOME TO SEARCH *************"<<endl;
cout<<"Enter a no phone:"<<endl;
cin>>src;
for(i=0;i<count;i++)
{
if(src==tell[i].no)
{
cout<<"Name is : "<<tell[i].fname<<endl;
cout<<"family is : "<<tell[i].lname<<endl;
cout<<"No. phone is : "<<tell[i].no<<endl;
}else
{
cout<<"No not found : :(";
}
}
break;
}
_getch();
}
حالا می خوام وقتی که مثلا شماره جدید درج شد بیاد دوباره پیغام رو نشون بده که می خواد به کدوم قسمت بره مربوط به switch ولی ارورر می ده نمیدونم چطور باید انجام بدم که بیاد سوال بپرسه به چه قسمتی بره ، مثلا اگه 3 رو وارد کرد قسمت چستجو رو فراخوانی کنه : شاید اصطلاح سویچ تو در تو باشه نمی دونم ..
ممنونم میشم دوستان کمک کنند :(
بنده در حال نوشتن پروژه دفتر تلفن هستم که با استراکت نوشتم کدش رو قرار میدم تا ببنید :
#include "stdafx.h"
#include<iostream>
#include<string>
#include<conio.h>
using namespace std;
struct tellphone{
char fname[100],lname[100];
double no;
};
int main()
{
int a=0,i,j,count=0;
char ans;
int src;
tellphone tell[100];
cout<<"************* WELCOME TO TELLPHONE menu ************* "<<endl;
cout<<"Enter 1 for insert : "<<endl;
cout<<"Enter 2 for edit : "<<endl;
cout<<"Enter 3 for search : "<<endl;
cin>>a;
switch(a)
{
case 1:
for(i=0;;i++)
{
cout<<"************* WELCOME TO Insert ************* "<<endl;
cout<<"Enter a first name : "<<endl;
cin.getline(tell[i].fname,30);
cout<<"Enter a Family : "<<endl;
cin.getline(tell[i].lname,30);
cout<<"Enter a No. phone : ";
cin>>tell[i].no;
cout<<"************* INSERT IS COMPLETE ************* "<<endl;
//cout<<"Do you want go to menu ? Y/N .... ";
count++;
//cin>>ans;
}
case 2:
cout<<"************* WELCOME TO EDIT *************"<<endl;
cout<<"Enter a no phone for edit :"<<endl;
cin>>src;
for(i=0;i<count;i++)
{
if(src==tell[i].no)
{
cout<<"Name is : "<<tell[i].fname<<endl;
cout<<"family is : "<<tell[i].lname<<endl;
cout<<"No.phone is : "<<tell[i].no<<endl;
cout<<"Enter a name for edit : "<<endl;
cin.getline(tell[i].fname,20);
cout<<"Enter a FAmily for edit : "<<endl;
cin.getline(tell[i].lname,20);
cout<<"Enter a no.phone for edit : "<<endl;
cin>>tell[i].no;
cout<<"*************EDIT it complete*************";
}else
{
cout<<"No not found :(";
}
}
//break;
case 3:
cout<<"************* WELCOME TO SEARCH *************"<<endl;
cout<<"Enter a no phone:"<<endl;
cin>>src;
for(i=0;i<count;i++)
{
if(src==tell[i].no)
{
cout<<"Name is : "<<tell[i].fname<<endl;
cout<<"family is : "<<tell[i].lname<<endl;
cout<<"No. phone is : "<<tell[i].no<<endl;
}else
{
cout<<"No not found : :(";
}
}
break;
}
_getch();
}
حالا می خوام وقتی که مثلا شماره جدید درج شد بیاد دوباره پیغام رو نشون بده که می خواد به کدوم قسمت بره مربوط به switch ولی ارورر می ده نمیدونم چطور باید انجام بدم که بیاد سوال بپرسه به چه قسمتی بره ، مثلا اگه 3 رو وارد کرد قسمت چستجو رو فراخوانی کنه : شاید اصطلاح سویچ تو در تو باشه نمی دونم ..
ممنونم میشم دوستان کمک کنند :(