turbo-c

how to convert this C++ code to Turbo C?

夙愿已清 提交于 2019-12-13 08:57:06
问题 C++ code: cout << "Roots are complex and different." << endl; cout << "x1 = " << realPart << "+" << imaginaryPart << "i" << endl; cout << "x2 = " << realPart << "-" << imaginaryPart << "i" << endl; How can I convert this to Turbo C like printf instead of cout ? 回答1: May be you are seeking for this: printf("Roots are complex and different.\n"); printf("x1 = %lf+%lfi\n",realPart,imaginaryPart); printf("x2 = %lf-%lfi\n",realPart,imaginaryPart); if realPart and imaginaryPart variables are in data

A weird behavior of C compilers GCC and Turbo [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-13 02:59:24
问题 This question already has answers here : Why are these constructs using pre and post-increment undefined behavior? (14 answers) Closed 5 years ago . I've gone through other similar questions, but trying to understand the situation I'm facing. So, here's my two line C code. int i=0; printf("%d %d %d %d %d",i++,i--,++i,--i,i); And here are the outputs I get from GCC and Turbo C Compiler. GCC Output: -1 0 0 0 0 Turbo C Output: -1 0 0 -1 0 I tried all sorts of experiments with pre-increment

How to include the basic header files which are available with C in UNIX?

落花浮王杯 提交于 2019-12-11 18:06:08
问题 When we work on Turbo C, we get all the functions and header files by default which we can include normally by #inlcude eg: stdlib.h, math.h But when writing a simple program using such header files I am getting error because I'm unable to include these files. Aren't these header files available by default for us to use? If yes then how to use such header files? When I used a function sqrt in "math.h" I was getting error as math.h was not getting included so I had to include it in the

Use of kbhit() with while loop

百般思念 提交于 2019-12-11 02:01:56
问题 Here is the program. void main( ) { int h, v; h = 1; v = 10; while ( !kbhit( ) || h <= 80 ) { gotoxy( h, v ); printf( "<--->" ); delay( 200 ); clrscr( ); h = h + 1; } getch( ); } I am making a program in C, in which I have used kbhit() to run a loop until a key is pressed. so here the arrow "<--->" will keep on moving forward until a key is pressed or until it reaches the last pixel of the screen. What I want is that the program should increment h by 1 everytime 'd' is pressed and decrement

In C, how do I write to a particular memory location e.g. video memory b800, in DOS (real DOS, MS DOS 6.22)

微笑、不失礼 提交于 2019-12-08 16:27:39
问题 In C, how do I write to a particular memory location e.g. video memory b800, in DOS (real DOS, MS DOS 6.22) I understand that C doesn't have anything built in to do that, but that there may be some platform specific e.g. DOS specific API functions that can. A small demo program that does it would be great. I have Turbo C (TCC.EXE - not tiny c compiler, Turbo C compiler) I know debug can do it (e.g. some of the tiny bit of debug that I know) -f b800:0 FA0 21 CE (that writes some exclamation

How to compile a program of c Language manually on MS DOS instead of Borland

元气小坏坏 提交于 2019-12-06 07:28:27
I need to compile a program in MS DOS. I have Borland Editor, I can compile it using Alt + F9 but the things is what it do at the backend. I want to compile it in MS DOS. I m trying this: c:\tc\bin>tcc -o hello.exe hello.c where hello.c is is my file, hello.exe the file I want to produce. Its not working, what shouldI do? and also please tell me also how do I compile .cpp file manually from MS DOS. I belive this things must work c:\tc\bin\tcc -c File.c \\ To generate objective file c:\tc\bin\tcc -o File.obj \\ To generate exe from obj and please use .obj and not .o c:\tc\bin\ tcc -run File.c \

How to make the last letter blink?

别来无恙 提交于 2019-12-04 07:02:04
问题 I'd recently created this program that displays the last letter of a string. Using this code: #include<conio.h> #include<string.h> #include<stdio.h> void main() { clrscr(); char text[255]; int length= strlen(text); char lastchar=text[length-1]; gets(text); cout<<lastchar; getch(); } If I use textattribute or textcolor+128 and change cout to cprintf(lastchar) I receive an error which says: cannot convert int to const* char" and "type mismatch in parameter '___format' in call to 'cprintf(const

Turbo C Array Question

前提是你 提交于 2019-12-02 17:32:29
问题 I just want to ask something about my code. #define LIM 40 main() { int day=0; float temp[LIM]; clrscr(); do { printf("Enter temperature for day %d.", day); scanf("%f", &temp[day]); } while(temp[day++] > 0) } I'm using TurboC, this code repeatedly asks the user to enter a temperature and stores the responses in the array temp , until a temperature of 0 or less is entered. I've used a #define directive to give the identifier LIM the value of 40 because I want this program to accept any number

How to make the last letter blink?

回眸只為那壹抹淺笑 提交于 2019-12-02 12:51:51
I'd recently created this program that displays the last letter of a string. Using this code: #include<conio.h> #include<string.h> #include<stdio.h> void main() { clrscr(); char text[255]; int length= strlen(text); char lastchar=text[length-1]; gets(text); cout<<lastchar; getch(); } If I use textattribute or textcolor+128 and change cout to cprintf(lastchar) I receive an error which says: cannot convert int to const* char" and "type mismatch in parameter '___format' in call to 'cprintf(const char*,....)' This is what you are looking for: //------------------------------------------------------

BGI error, How to Resolve it?

橙三吉。 提交于 2019-12-01 09:12:13
I want to run a C program that draws a circle. The program is compiling with no error and it is running. After getting the values like radius from the user, I get the error like this : BGI error: Graphics not initialized ( use "initgraph") Even though in my source code I have added this line : int gmode,gdrive=DETECT; initgraph(&gdrive,&gmode,"c\\tc\\bgi"); Still I'm getting error. I'm using Windows and I couldn't figure out where I went wrong. Can anyone help me in this regard? Thanks in advance. Jesus Ramos Your path in initgraph is wrong. Use "c:\\tc\bgi" instead. montej I also suffered