标签: turbo-c++

NULL指针赋值错误

您好我已经写了以下代码Turbo c++ compiler并尝试打印postfix和中缀,但它正在显示NULL pointer assignment.我不知道为什么会发生这种情况.请帮我....

提前致谢.

#include<iostream.h>
#include<stdio.h>

void main()
{
     char *infix,*postfix;
     cout<<"Enter postfix exp:";
     gets(postfix);
     cout<<"Enter infix exp: ";
     gets(infix);
     cout<<endl<<endl;
     puts(postfix);
     puts(infix);
}
Run Code Online (Sandbox Code Playgroud)

c++ turbo-c++

0
推荐指数
1
解决办法
1870
查看次数

Turbo C++和GCC(在Windows上使用代码块)以不同方式评估相同的三元表达式

我有这个表达

(*p % 3 != 0) ? *p = (*p) + 1 : *p = (*p) + 2;
Run Code Online (Sandbox Code Playgroud)

在Turbo C++中,如果*p为11,则计算结果为14;如果*p为33,则计算结果为35

在GCC(Windows)中,它分别评估为12和35,这是预期的

括号为以下格式时,它工作正常:

(*p % 3 != 0) ? (*p = (*p) + 1) : (*p = (*p) + 2); 
Run Code Online (Sandbox Code Playgroud)

这种差异有什么解释吗?我猜它归结为编译器使用的优先顺序的差异,但无法确定根本原因

c++ gcc turbo-c++ operator-precedence

0
推荐指数
1
解决办法
471
查看次数

指针递增和递减

我正在解决老师给我的一个问题并且遇到了一些问题.我应该给出以下代码的输出:(用Turbo C++编写)

#include<iostream.h>
void main()
{
    char *p = "School";
    char c;
    c=++(*(p++));
    cout<<c<<","<<p<<endl;
    cout<<p<<","<<++(*(p--))<<","<<++(*(p++))<<endl;

}
Run Code Online (Sandbox Code Playgroud)

程序给出的输出是:

T,chool
ijool,j,i
Run Code Online (Sandbox Code Playgroud)

我得到了指针本身增量的部分,然后递增指针指向.但我没有得到字符串打印出来的部分ijool

有人可以帮我吗?

c++ pointers turbo-c++

0
推荐指数
1
解决办法
1955
查看次数

增加字符串文字中的字符

    #include<stdio.h>
    int main(){
       char *ptr="Helio";
       ptr++;
       printf("%s\n",ptr);
       //*ptr++;
       printf("%c\n",++*ptr);/*Segmentation fault on GCC*/
       return 0;
    }
Run Code Online (Sandbox Code Playgroud)

Q1)这在Turbo C++中运行良好,但在GCC上它会产生分段错误.我没有得到确切的理由.

可能是运营商优先是其中一个原因.

Q2)每个编译器都有不同的运算符优先级吗?

正如我在这里看到的, ++具有比解除引用运算符更高的优先级.可能是GCC和Turbo C++对待它们的方式不同.

c c++ gcc turbo-c++

0
推荐指数
1
解决办法
224
查看次数

代码错误:代码无效

以下是我的代码.此代码在屏幕上移动文本.我正在做一个在学校提交的项目.遗憾的是,我们的项目必须使用Turbo C++而不是Visual Studio或CodeBlocks.

#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
int main()
{
    for(int fp=0, sp=getmaxx();fp <= (getmaxx()/4)-20, sp >= (getmaxx()/2)+60; fp++, sp--)
    {
        cleardevice();
        setfillstyle(SOLID_FILL,RED);
        bar(320,50,340,170);
        bar(270,100,390,120);
        settextstyle(SCRIPT_FONT,HORIZ_DIR,5);
        outtextxy(fp-125,300,"Welcome To ");
        outtextxy(sp,300,"MedStore");
        delay(10);
    }
    getch();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

编译器显示错误

代码没有效果

有人可以指导我解决这个错误吗?

c++ turbo-c++

0
推荐指数
1
解决办法
1517
查看次数

如何将Turbo-C远端指针分配和取消引用转换为x86程序集?

我要进行汇编测试,并且对汇编指针有疑问。我正在尝试锻炼,但无法解决。

考虑一下C中的语句:

int x=100, y=200;
int far *ptx;
int far *pty;
Run Code Online (Sandbox Code Playgroud)

假设指令已经执行:

ptx=&x;
pty=(int *)malloc(sizeof(int));   
Run Code Online (Sandbox Code Playgroud)

我的问题是关于如何在汇编中编码以下几点:

  1. ptx=pty
  2. *ptx=*pty

c assembly tasm turbo-c++ x86-16

0
推荐指数
1
解决办法
157
查看次数

我的C++代码不起作用

我是C++编程的学生我正在尝试用c ++创建一个年龄计算器,但我坚持将变量与另一个变量相乘这里是代码:

#include <iostream.h>
#include <conio.h>
void main()
{
    clrscr();
    int birthmonth,birthyear,birthdate;
    int currentmonth,currentyear,currentdate;
    int year,month,weeks,cal,calx,days,hours;
    cout<<"Hassan's Age Calculator\n\n";
    cout<<"Enter Your Birth Year(i.e:1996):";
        cin>>birthyear;
    cout<<"\nEnter Your Birth Month(i.e:10):";
        cin>>birthmonth;
    cout<<"\nEnter date of Birth(i.e:27):";
        cin>>birthdate;
    cout<<"\nEnter The Current Month(i.e:7):";
        cin>>currentmonth;
    cout<<"\nEnter The Current Year(i.e:2013):";
        cin>>currentyear;
    cout<<"\nEnter Current Date(i.e:24):";
        cin>>currentdate;
    year=currentyear-birthyear;
    month=year*12;
    weeks=month*4.34;
    cal=(year*365.242)+currentdate;
    calx=cal+30.43;
    days=calx-birthdate;
    hours=days*24;

    cout<<"\n\n\t\tYour Age is "<<year<< " in Years" ;
    cout<<"\n\n\t\tYour Age is "<<month<< " in Months" ;
    cout<<"\n\n\t\tYour Age is "<<weeks<<" in weeks";           
    cout<<"\n\n\t\tYour Age is …
Run Code Online (Sandbox Code Playgroud)

c++ turbo-c++

-1
推荐指数
1
解决办法
443
查看次数

如何使用 Turbo C++ 并行运行两种功能,一种用于键盘,一种用于鼠标?

我正在尝试使用 Turbo-C++ 同时获得鼠标和键盘输入。

我想使用两个函数。第一个函数是main可以接受键盘输入或调用该delay函数dos.h以暂时停止main().

第二个函数处理鼠标输入:

void mouse()
 {
    union REGS in,out;
    in.x.ax=1; // Show mouse pointer
    int86(0x33,&in,&out); //interrupt call
    while(1)
     {
       //print the location whenever it changes (not required)
     }
 }
Run Code Online (Sandbox Code Playgroud)

c++ interrupt turbo-c++ low-level

-1
推荐指数
1
解决办法
155
查看次数

C++中的类和对象

class anurag
{
private:
int rollno;
char name[50];
int marks;
float percen;
void percentage(int num)   
{
 percen=(num/500)*100;

}
public:
void getdata(void)
{
cout<<"\n\nEnter the name of the student:";
gets(name);
cout<<"\n\nEnter the roll no: and the marks:";
cin>>rollno>>marks;
percentage(marks);
}
void display(void)
{
cout<<"\n\nThe name of the student is:";
cout.write(name,50);
cout<<"\n\nThe roll no: of the student is:";
cout<<rollno;
cout<<"\n\n The marks obtained is:"<<marks;
cout<<"\n\nThe percentage is:"<<percen;
}};
   void main()
   {
clrscr();
anurag F;
F.getdata();
F.display();
getch();
   }
Run Code Online (Sandbox Code Playgroud)

为什么以下代码没有提供所需的输出?

c++ turbo-c++

-3
推荐指数
1
解决办法
2906
查看次数

声明终止不正确

完整的代码是正确的,但我在第28行只得到了这一个错误:declaration terminated incorrectly.

#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
#include<iostream.h>
class Rail
{
private:
char GetYN();
struct Train
{
    int tno, nop;
    char tname[50];
    char dest[50];
    float dist, fare;
}t;
public:
void Input();
void CreateFile();
void Display();
void Search();
void Modify();
void Delete();
void AddRecord();
}R;
void introduction();
{                         \\This is where the error is (error: declaration terminated incorrectly)
clrscr()
cout << "\n\n";
cout << "\t  =============================================================\n";
cout << "\t  **                                                         **\n";
cout << "\t  **                       WELCOME TO                        **\n"; …
Run Code Online (Sandbox Code Playgroud)

c++ turbo-c++ borland-c++

-6
推荐指数
1
解决办法
8139
查看次数