PDA

View Full Version : ارور در زمان کامپایل در لینوکس



C0NN3CT0R
چهارشنبه 09 شهریور 1390, 16:28 عصر
با سلام .. بچه ها من این برنامه رو نوشتم وقتی می خوام کامپایلش کنم در لینوکس اررور میده...
#include <iostream>
using namespace std;
int main ()
{
for(char ch=-128;ch<127;ch++)
cout<<"Character= " <<ch<<"\tASCII Code"<<(int)ch<<"\n";
cout<<"Character="<<ch<<"\tASCII Code"<<(int)ch<<endl;
return 0;
}
ارور


in function 'int main ()':
error: name lookup of 'ch' changed for iso 'for' scoping
note: (if you use '-fpermissive' g++ will accept your code)

حامد مصافی
چهارشنبه 09 شهریور 1390, 17:06 عصر
#include <iostream>
using namespace std;
int main ()
{
for(char ch=-128;ch<127;ch++){
cout<<"Character= " <<ch<<"\tASCII Code"<<(int)ch<<"\n";
cout<<"Character="<<ch<<"\tASCII Code"<<(int)ch<<endl;
}

return 0;
}

C0NN3CT0R
سه شنبه 15 شهریور 1390, 13:19 عصر
این برنامه رو هم هر کاری می کنم اجرا نمیشه مشکل کجاست؟

#include <iostream>
#include <conio.h>
using namespace std;
#include <windows.h>
void gotoxy(int, int);//prototype
void clrscr();//prototype
int main()
{
//move in to four corners of the screen.
clrscr ();//function call
gotoxy(0,25);//move to begin of the last line
char U=24,D=25,R=26,L=27;//ASCII Code Of 4 Vectors
cout<<"Use These Keys For Move:\t"
<<"U="<<U<<"\tD="<<D<<"\tR="<<R<<"\t"<<L;
char sg=1,ch=0;//sg has the ASCIICode Of...
int x=39,y=11;//x and y store position of cursor
gotoxy(x,y);//move to center of screen.
cout.put(sg);
gotoxy(x,y);//return to previous position.
while((ch=getch())!=27)
{
//start getting command of user.
if ((ch=='u'||ch=='U') && y>1)
{
cout.put('');
gotoxy(x,--y);
cout.put(sg);
gotoxy(x,y);
}
else if((ch=='d'||ch=='D') && y<24)
{
cout.put('');
gotoxy(x,++y);
cout.put(sg);
gotoxy(x,y);
}
else if((ch=='r'||ch=='R') && x<79)
{
cout.put('');
gotoxy(++x,y);
cout.put(sg);
gotoxy(x,y);
}
else if ((ch=='l'||ch=='L')&& x>0)
{
cout.put('');
gotoxy(--x,y);
cout.put(sg);
gotoxy(x,y);
}
}//end of while
clrscr();
return 0;
}
//function definition -- requires windows.h
void gotoxy(int x, int y)
{
HANDLE hConsoleOutput;
COORD dwCursorPosition;
cout.flush();
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput,dwCursorPo sition);
}
void clrscr()
{
system("CLS");
}

حامد مصافی
سه شنبه 15 شهریور 1390, 13:46 عصر
این برنامه از توابع سیستم عامل ویندوز استفاده کرده

C0NN3CT0R
سه شنبه 15 شهریور 1390, 18:47 عصر
داخل DEV C++ توی ایکس پی هم خواستم اجراش کنم نشد...

کامپایل شد ها اما run نشد....

mrsajjad
چهارشنبه 16 شهریور 1390, 14:54 عصر
سلام دوست عزيز
شما بايد در Linux Suse اين کار را انجام بدهيد . بعد در قسمت YaSt رفته و Software Manger کامپايلر gccرا جستجو و کامل نصب کنيد . بعد يکسري دستورات خاص هست براي اجرا . در ضمن بايد تمامي کارها را توسط تابع انجام دهيد و بعد در آخر آدرس فايل cpp را داده و با -o خورجي مي گيري . سوال بيشتر داشتي بپرس .

_hamid
چهارشنبه 16 شهریور 1390, 23:26 عصر
نه عزیز من کد شما داره از کتابخانه‌ی خانمان سوزconio که واسه توربو سی هست استفاده می کنه.
یه پروژه‌ی متن باز واسه این کتابخانه هستش با همین اسم.
بگرد اگر خیلی پایه ای.