在我的大学里,他们为我的学者开了Turbo C. 我知道它已经很老了,但我想下载它的最新版本.我有一个1980年的涡轮增压器,一个DOS版本.
有没有最新版本?
Borland C++与Turbo C++有什么不同?
我经历过其他类似的问题,但试图了解我所面临的情况.
所以,这是我的两行C代码.
int i=0;
printf("%d %d %d %d %d",i++,i--,++i,--i,i);
Run Code Online (Sandbox Code Playgroud)
以下是我从GCC和Turbo C编译器获得的输出.
输出:
-1 0 0 0 0
Run Code Online (Sandbox Code Playgroud)
输出:
-1 0 0 -1 0
Run Code Online (Sandbox Code Playgroud)
我尝试了单独使用预增量运算符的各种实验,并且两个编译器的工作方式相似,但是当我使用上面的printf
语句时,输出会有所不同.
我知道Turbo C是一个古老的编译器,现在已经过时和非标准,但仍无法弄清楚上面的代码有什么问题.
O/p出现为x = 2,y = 1,z = 1,这与运算符优先级不一致.我在Turbo c ++编译器上运行它:
void main()
{
int x,y,z,q;
x=y=z=1;
q=++x || ++y && ++z;
printf("x=%d y=%d z=%d",x,y,z);
}
Run Code Online (Sandbox Code Playgroud) 在下面的程序中,我试图将三角形旋转45度反向旋转.多边形确实旋转到某个角度并转换到其他位置.请告诉我这是如何解决的.
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
int main(void)
{
int poly[8], rpoly[8],angle;
int gd = DETECT, gm;
initgraph(&gd,&gm,"C:\\TC\\BGI");
printf("\n Enter co-ordinates for Triangle : \n\n");
printf("Vertex 1 (x,y) : ");
scanf("%d %d", &poly[0], &poly[1]);
printf("Vertex 2 (x,y) : ");
scanf("%d %d", &poly[2], &poly[3]);
printf("Vertex 3 (x,y) : ");
scanf("%d %d", &poly[4], &poly[5]);
poly[6] = poly[0];
poly[7] = poly[1];
setcolor(2);
drawpoly(4,poly);
angle = 45;
rpoly[0] = poly[0]*cos(angle) - poly[1]*sin(angle);
rpoly[1] = poly[0]*sin(angle) + poly[1]*cos(angle);
rpoly[2] = poly[2]*cos(angle) - poly[3]*sin(angle);
rpoly[3] = poly[2]*sin(angle) …
Run Code Online (Sandbox Code Playgroud) 可能重复:
没有标题的C程序
我一直在学习C语言.但是困扰我的一件事是,今天我做了一个C程序而忘记包含stdio.h和conio.h头文件我把文件保存为kc.c?当我编译并运行这个.c文件时,输出就像我期望的那样.
但是如何在不使用标准头文件的情况下运行C程序?
或者我不知道我失踪的概念听到了什么?
编辑:该计划
int main()
{
int i=12,j=34;
int *pa=&i,*pb=&j;
printf("the value of i and j is %d %d respectively ",*pa,*pb);
getch();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
因为我在这里使用了STDIO.H头的printf()函数,但没有包括它如何编译并成功运行?
为什么在Turbo C++ IDE中,硬编码值65536的整数变量的输出为0且小于该值(65536)为负整数且大于该值(65536)为正整数?
如果我们初始化一个硬编码值为65536的整数并打印它,它将打印0,如果我们将该整数变量的值从65536更改为65535或更小,如65534,依此类推它打印-1,-2,. ..如果我们将该整数变量的值从65536更改为65537或更高,它将打印1,2,3 ...依此类推,为什么会发生这种情况?我在Turbo C++ IDE上验证了它.
因为我是初学者,请清楚地解释逻辑并在此背后明确地工作.
我很久以前就遇到过一些用旧的非ansi C编写的旧代码,我试图了解函数定义.
我可以理解最终结果,但我想完全理解代码风格..
使用:
ok = ElementFn(lifestyleRollupContribution)( gr, nr, cnt, id, prj, k, f, rnd, base );
Run Code Online (Sandbox Code Playgroud)
功能定义:
Private Logical ElementFn(lifestyleRollupContribution)
(
Real* gross,
Real* net,
Const Real* contribution,
Const Date* investment,
Const Date* projection,
Const PCode* key,
Const PCode* fund,
Const PCode* inv_prd_round,
Const Date* inv_prd_base_date
)
{
// stuff
}
Run Code Online (Sandbox Code Playgroud)
所以在这个例子中,我可以看到一个名为ElementFN的函数,它返回一个"逻辑"并且有许多参数.我没有得到的是什么(lifestyleRollupContribution)它只在你看到它的地方使用了两次......但是它在做什么?它表示什么 - 我不认识.我见过对Kernighan和Ritchie样式函数声明的引用,但这似乎不是那样的?
我写了以下C程序:
#include<stdio.h>
#include<stdlib.h>
void main()
{
int count;
scanf("%d",&count);
if(count < 1 || count > 100)
{
exit(1);
}
int inputs[10];
for(int i = 0; i < count; i++)
{
scanf("%d",&inputs[i]);
if(inputs[i] < 1 || inputs[i] > 30000)
{
exit(1);
}
}
for(i = 0; i < count; i++)
{
printPrimeFactor(inputs[i], 2);
printf("\n");
}
}
void printPrimeFactor(int number, int factor)
{
if(number % factor == 0)
{
int flag = 1, newNumber;
newNumber = number;
for(int i = 0; i …
Run Code Online (Sandbox Code Playgroud) 我已经开始使用Turbo C 2.01作为业余爱好项目.是的,DOS版本.自1987年问世以来,我认为它不支持C90 ......除此之外.好吧,它的碎片.该volatile
关键字的工作.并且不支持直接K&R; 我尝试了K&R样式声明,出错了.
所以,我想知道什么形式的C Turbo C使用.我敢肯定它是非标准的,但似乎有些一致,而且由于这是当天非常受欢迎的编译器,我确信有一些信息收集......对吗?
我正在使用 DOS 虚拟机绕过段错误,但 Turbo-C 不想编译此代码:
#include <stdio.h>
int main() {
FILE *fp = fopen("somefile.txt", "w");
if(fp == NULL) {
fprintf(stderr, "NaF");
return -1;
}
char /*1*/ *ch = NULL;
while(ch /*2*/ < (char *) 209* /*3*/1024) {
fprintf(fp, "& - %p, * - %c\n", ch, *ch/*4*/);
ch++;
}
fclose(fp);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
错误列表:
我认为这一定是某种古老的 C,因为我确信这段代码可以在现代编译器上编译。我知道它会产生段错误,因此我在 DOS 环境中编写。