PDA

View Full Version : سوال: error C1083: Cannot open include file: 'stdlib': No such file or directory



adonis27
شنبه 14 اردیبهشت 1392, 22:32 عصر
سلام چرا این کد ارور میگیره

اینم ارورش
proje daftarche telephon.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\proje daftarche telephon\proje daftarche telephon.cpp(3) : fatal error C1083: Cannot open include file: 'stdlib': No such file or directory
Error executing cl.exe.


#include<iostream.h>
#include<string.h>
#include<stdlib>

#define N 100


struct tellephone
{
string fname;
string lname;
string address;
string tell;
};
tellephone list[N];

void print_menu();
void add_contact(int &);
void search(int,int);
void show_list(int);
void index_show(int,int);
void edit_contact(int,int);
void delete_contact(int,int &);

int main ()
{
char ans,pause;
int top=-1;
bool quit=0;
while (!quit)
{
print_menu();
cin>>ans;
switch(ans)
{
case '1': //add contact
add_contact(top);
break;
case '2': //search by name
search(top,1);
break;
case '3': //search by number
search(top,2);
break;
case '4': //show list
show_list(top);
break;
case '5': //show by index
search(top,3);
break;
case '6': //quit
quit=1;
break;
default:
cout<<"\t\terror !!! unknown input .\n";
break;
}
if(quit)
{
cout<<"final list :\n";
show_list(top);
}
cout<<"enter a character to continue ...";
cin>>pause;
}
return 0;
}
void print_menu()
{
clear_screen();
cout<<"1-add contact\n2-search by name\n3-search by number\n4-show list\n5-show by index\n6-quit\n";
}
void add_contact(int &top)
{
if (top>N)
cout<<"\t\terror !!! list is full .\n";
else
{
top++;
cout<<"enter fname::\n";
getline(cin,list[top].fname);
getline(cin,list[top].fname);
cout<<"enter lname::\n";
getline(cin,list[top].lname);
cout<<"enter address::\n";
getline(cin,list[top].address);
cout<<"enter tell::\n";
getline(cin,list[top].tell);
}
}

void search(int top,int mode)
{
if(top==-1)
cout<<"\t\terror !!! list is empty .\n";
else
{
bool found=0;
int index;
string fname,lname,tell;
switch (mode)
{
case 1:
cout<<"enter fname::\n";
getline(cin,fname);
getline(cin,fname);
cout<<"enter lname::\n";
getline(cin,lname);
for(int i=0;i<=top && !found;i++)
if(fname==list[i].fname && lname==list[i].lname)
{
found=1;
index=i;
}
break;
case 2:
cout<<"enter tell::\n";
getline(cin,tell);
getline(cin,tell);
for(int i=0;i<=top && !found;i++)
if(tell==list[i].tell)
{
found=1;
index=i;
}
break;
case 3:
cout<<"enter index number::\n";
cin>>index;
if(index<=top&&index>-1)
found=1;
break;
default:
cout<<"\t\terror !!! invalid input for search mode . contact programmer .\n";
break;
}
if(found)
{
cout<<"\t\tcontact found . contact info :\n";
index_show(index,top);
cout<<"1-edit contact info\n2-delete contact from list\n3-do nothing\n";
char ans;
cin>>ans;
switch(ans)
{
case '1': //edit contact
edit_contact(index,top);
break;
case '2': //delete contact
delete_contact(index,top);
break;
case '3':
break;
default:
cout<<"\t\terror !!! unknown input . we do nothing\n";
break;
}
}
else
cout<<"\t\terror !!! contact not found .\n";
}
}

void show_list(int top)
{
if(top==-1)
cout<<"\t\terror !!! list is empty .\n";
else
{
for(int i=0;i<=top;i++)
{
index_show(i,top);
}
cout<<"\t\ttotal records =\t"<<top+1<<endl;
}
}

void index_show(int index,int top)
{
if(index>top || index <0)
{
cout<<"\t\terror !!! entered index is wrong .\n";
return ;
}
if(top==-1)
{
cout<<"\t\terror !!! list is empty .\n";
return ;
}
cout<<list[index].fname<<"\t"<<list[index].lname<<"\n"
<<list[index].address<<"\n"<<list[index].tell<<"\n\n";
}

void edit_contact(int index,int top)
{
if(index>top || index <0)
{
cout<<"\t\terror !!! entered index is wrong .\n";
return ;
}
if(top==-1)
{
cout<<"\t\terror !!! list is empty .\n";
return ;
}
add_contact(--index);
cout<<"\t\tchanges applied\n\n";
index_show(index+1,top);
}

void delete_contact(int index, int &top)
{
if(index>top || index <0)
{
cout<<"\t\terror !!! entered index is wrong .\n";
return ;
}
if(top==-1)
{
cout<<"\t\terror !!! list is empty .\n";
return ;
}
if(index<top)
for(int i=index;i<top;i++)
{
list[i].fname=list[i+1].fname;
list[i].lname=list[i+1].lname;
list[i].address=list[i+1].address;
list[i].tell=list[i+1].tell;
}
top--;
cout<<"\t\tthe cotact is deleted . total records :\t"<<top+1<<endl;
}

void clear_screen()
{
system("clear");
}

adonis27
شنبه 14 اردیبهشت 1392, 23:07 عصر
هیچکی نیست

mahak006
شنبه 14 اردیبهشت 1392, 23:34 عصر
هیچکی نیست
stdlib.h بزن به جاش . شاید درست شه .
یه مطلبی رو فراموش کردم بهت بگم .
در کل کدهایی که تو لینوکس نوشته می شن ( به زبان C++‎ و با کامپایلر g++ ) بدون تغییر می تونن تو ویژوال بیسیک ویندوز و ... اجرا بشن . اما تو حالت های خاصی که تو کد فراخوانی دستور سیستمی داریم ، باید دستور سیستمی معادل تو سیستم عامل مورد نظر رو قرار بدی . مثلا تو سیستم عامل ویندوز system("cls") داریم . در حالی که تو لینوکس system("clear") وجود داره .
این قسمت کد رو تو بالا عوض کن . ببین تو ویندوز اجرا می شه .

adonis27
شنبه 14 اردیبهشت 1392, 23:43 عصر
درست نشد
من به stdlib .h اضافه میکنم ارورش بیشتر میشه

saied_hacker
یک شنبه 15 اردیبهشت 1392, 09:04 صبح
این کد به طور کامل اجرا شد و مشکلی هم نداشت ؟

خط هایی رو که تغییر دادم با * مشخص کردم.
string هم تو نیم اسپیس std هس باید اضافه کنی...
توی کامپایلر های جدید هم iostream بدون h هست


#include<iostream> //*
#include<string.h>
#include <stdlib.h> //*

#define N 100

using namespace std; //*
struct tellephone
{
string fname;
string lname;
string address;
string tell;
};
tellephone list[N];

void print_menu();
void add_contact(int &);
void search(int,int);
void show_list(int);
void index_show(int,int);
void edit_contact(int,int);
void delete_contact(int,int &);
void clear_screen();

int main ()
{
char ans,pause;
int top=-1;
bool quit=0;
while (!quit)
{
print_menu();
cin>>ans;
switch(ans)
{
case '1': //add contact
add_contact(top);
break;
case '2': //search by name
search(top,1);
break;
case '3': //search by number
search(top,2);
break;
case '4': //show list
show_list(top);
break;
case '5': //show by index
search(top,3);
break;
case '6': //quit
quit=1;
break;
default:
cout<<"\t\terror !!! unknown input .\n";
break;
}
if(quit)
{
cout<<"final list :\n";
show_list(top);
}
cout<<"enter a character to continue ...";
cin>>pause;
}
return 0;
}
void print_menu()
{
clear_screen();
cout<<"1-add contact\n2-search by name\n3-search by number\n4-show list\n5-show by index\n6-quit\n";
}
void add_contact(int &top)
{
if (top>N)
cout<<"\t\terror !!! list is full .\n";
else
{
top++;
cout<<"enter fname::\n";
getline(cin,list[top].fname);
getline(cin,list[top].fname);
cout<<"enter lname::\n";
getline(cin,list[top].lname);
cout<<"enter address::\n";
getline(cin,list[top].address);
cout<<"enter tell::\n";
getline(cin,list[top].tell);
}
}

void search(int top,int mode)
{
if(top==-1)
cout<<"\t\terror !!! list is empty .\n";
else
{
bool found=0;
int index;
string fname,lname,tell;
switch (mode)
{
case 1:
cout<<"enter fname::\n";
getline(cin,fname);
getline(cin,fname);
cout<<"enter lname::\n";
getline(cin,lname);
for(int i=0;i<=top && !found;i++)
if(fname==list[i].fname && lname==list[i].lname)
{
found=1;
index=i;
}
break;
case 2:
cout<<"enter tell::\n";
getline(cin,tell);
getline(cin,tell);
for(int i=0;i<=top && !found;i++)
if(tell==list[i].tell)
{
found=1;
index=i;
}
break;
case 3:
cout<<"enter index number::\n";
cin>>index;
if(index<=top&&index>-1)
found=1;
break;
default:
cout<<"\t\terror !!! invalid input for search mode . contact programmer .\n";
break;
}
if(found)
{
cout<<"\t\tcontact found . contact info :\n";
index_show(index,top);
cout<<"1-edit contact info\n2-delete contact from list\n3-do nothing\n";
char ans;
cin>>ans;
switch(ans)
{
case '1': //edit contact
edit_contact(index,top);
break;
case '2': //delete contact
delete_contact(index,top);
break;
case '3':
break;
default:
cout<<"\t\terror !!! unknown input . we do nothing\n";
break;
}
}
else
cout<<"\t\terror !!! contact not found .\n";
}
}

void show_list(int top)
{
if(top==-1)
cout<<"\t\terror !!! list is empty .\n";
else
{
for(int i=0;i<=top;i++)
{
index_show(i,top);
}
cout<<"\t\ttotal records =\t"<<top+1<<endl;
}
}

void index_show(int index,int top)
{
if(index>top || index <0)
{
cout<<"\t\terror !!! entered index is wrong .\n";
return ;
}
if(top==-1)
{
cout<<"\t\terror !!! list is empty .\n";
return ;
}
cout<<list[index].fname<<"\t"<<list[index].lname<<"\n"
<<list[index].address<<"\n"<<list[index].tell<<"\n\n";
}

void edit_contact(int index,int top)
{
if(index>top || index <0)
{
cout<<"\t\terror !!! entered index is wrong .\n";
return ;
}
if(top==-1)
{
cout<<"\t\terror !!! list is empty .\n";
return ;
}
add_contact(--index);
cout<<"\t\tchanges applied\n\n";
index_show(index+1,top);
}

void delete_contact(int index, int &top)
{
if(index>top || index <0)
{
cout<<"\t\terror !!! entered index is wrong .\n";
return ;
}
if(top==-1)
{
cout<<"\t\terror !!! list is empty .\n";
return ;
}
if(index<top)
for(int i=index;i<top;i++)
{
list[i].fname=list[i+1].fname;
list[i].lname=list[i+1].lname;
list[i].address=list[i+1].address;
list[i].tell=list[i+1].tell;
}
top--;
cout<<"\t\tthe cotact is deleted . total records :\t"<<top+1<<endl;
}

void clear_screen()
{
system("cls"); //*
//system("clear");
}

developing
دوشنبه 16 اردیبهشت 1392, 10:08 صبح
با سلام



در کل کدهایی که تو لینوکس نوشته می شن ( به زبان C++‎‎ و با کامپایلر g++ ) بدون تغییر می تونن تو ویژوال بیسیک ویندوز و ... اجرا بشن .

توی ویژوال بیسیک؟؟؟؟؟:متفکر::متعجب:
فکر کنم منظور شما ویژوال استودیو باشه.