turbo-c

pre and post increment operations on a variable give different output on TC and gcc [duplicate]

蹲街弑〆低调 提交于 2019-12-19 09:44:22
问题 This question already has answers here : Why are these constructs using pre and post-increment undefined behavior? (14 answers) Closed last year . Here is my simple code ... #include<stdio.h> int main() { int i=5; printf("%d %d %d %d %d ",i++,i--,++i,--i,i); return 0; } On gcc,it gives output as '4 5 5 5 5' but on TC,it gives output as '4 5 5 4 5' what I know that in printf statement,evaluation will be from left to right if it is a single expression but in normal statement,it will be from

Handling A Keyboard Interrupt with Turbo C ++ 3.0

折月煮酒 提交于 2019-12-19 04:46:32
问题 I have a project. That is a simple game , "Falling Blocks" . The game area is considered as a grid, which has 20x20 size. There will be falling blocks from top of the screen and a hero at the bottom, who will shoot the blocks. The aim of game is shooting blocks before they reach the bottom line. He always stays at the bottom line . Whenever the user press space button of the keyboard I will generate a bullet, and the hero moves on the bottom line with the right and left arrow keys. I do not

How to prevent duplicate chars when I press keys on the keyboard

江枫思渺然 提交于 2019-12-19 03:53:33
问题 I am trying to learn how to prevent the keyboard sending multiple chars to the screen and to scanf under DOS. I am using Turbo-C with inline assembly. If the characters entered on the keyboard are: mmmmmmmmyyyyy nnnnnaaaaammmmmmeeeeee iiiiiissss HHHHaaaaiiiimmmm The characters seen on the console and processed by scanf would be: my name is Haim The basic output comes from the code in C which I am not allowed to touch. I must implement eliminate_multiple_press and uneliminate_multiple_press

Windows.h in C using Turbo-C

笑着哭i 提交于 2019-12-18 07:05:54
问题 I cannot find windows.h in my include folder of Turbo C and hence cannot work with the Win32 api's Can someone please suggest a workaround? thanks 回答1: You could download Borland C++ 5.5. If memory serves, it can handle Windows programming "out of the box" (Warning: but it doesn't include an IDE of any kind, only command-line tools). Alternatively, you could look into any of several alternatives such as Dev-C++, Visual Studio Express, Cygwin, or Digital Mars. Edit: Or Code::Blocks, Ultimate++

Why the range of int is -32768 to 32767? [closed]

梦想的初衷 提交于 2019-12-17 15:44:59
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Why the range of any data type is greater on negative side as compare to positive side? For example, in case of integer: In Turbo C its range is -32768 to 32767 and for Visual Studio it is -2147483648 to 2147483647 . The same happens to other data types... [UPD: Set proper limit values for Visual Studio ] 回答1:

Problem with operator precedence [duplicate]

a 夏天 提交于 2019-12-17 14:57:05
问题 This question already has answers here : Why does “++x || ++y && ++z” calculate “++x” first, even though operator “&&” has higher precedence than “||” (11 answers) Closed last year . The O/p comes out to be x=2,y=1,z=1 which doesnt agree with the operator precedence. I was running this on Turbo c++ compiler: 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); } 回答1: Operator precedence does not in any way determine the order in which the operators are

Errors using ternary operator in c

做~自己de王妃 提交于 2019-12-17 07:53:08
问题 I have a piece of code in C given as follows : main() { int a=10, b; a>=5 ? b=100 : b=200 ; printf("%d" , b); } running the code on gcc compiler in unix generates the compile-time error as 'lvalue required as left operand of assignment' and points the error at b = 200 whereas in windows compiling using Turbo C gives 200 as output. Can anybody please explain what exactly is happening in this case ? 回答1: In C the ternary operator is defined like logical-OR-expression ? expression : conditional

Errors using ternary operator in c

时光毁灭记忆、已成空白 提交于 2019-12-17 07:53:08
问题 I have a piece of code in C given as follows : main() { int a=10, b; a>=5 ? b=100 : b=200 ; printf("%d" , b); } running the code on gcc compiler in unix generates the compile-time error as 'lvalue required as left operand of assignment' and points the error at b = 200 whereas in windows compiling using Turbo C gives 200 as output. Can anybody please explain what exactly is happening in this case ? 回答1: In C the ternary operator is defined like logical-OR-expression ? expression : conditional

Graphical functions in C

和自甴很熟 提交于 2019-12-13 13:29:55
问题 Why I see nothing when I run my code ? I use DOSBox. #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <dos.h> #include <conio.h> #include <bios.h> #include <ctype.h> #include <math.h> int main() { int gdriver = DETECT,gmode = 0; initgraph(&gdriver,&gmode,"C:\\TC\\BGI"); struct time t; moveto(5,10); outtext("Hello"); moveto(6,11); outtext("World**strong text**"); moveto(1,24); outtext("Press: 1-About_Author, 2-Current_Time,ESC to EXIT"); closegraph(); return 0; } 回答1: Your

Image output in C

丶灬走出姿态 提交于 2019-12-13 09:55:46
问题 Quick question, is there a way to show an image(ex. bmp) from file using C? It's not in graphics.h apparently, and I can't use Allegro because it does not support Borland(or so I've read). I need to use the very old compiler for a school project. I would like to ask if anyone had any experience of doing this using other libraries? If yes, which library was it? Thanks a lot. 回答1: I hope you have visual (windows) borland like Borland C++ builder 3++ or turbo C++ not the MS DOS one. in that case