Author Topic: new-b  (Read 9280 times)

BMB

  • Guest
new-b
« on: October 04, 2007, 11:29:20 pm »
Hi.
I've been programming for years with all flavors of BASIC, and have recently decided to switch to c/c++. I wrote a few programs while learning using Borland's Turbo C++ compiler 1.01, in other words, for DOS. Since I rather like a few of those programs, I wanted to recompile them to be native win32 programs (I think what I want is a console program, but I don't exactly know the difference between all those different types of programs. My only experience with window's programming is VB6). I am using the latest build of Code::Blocks and the MinGW compiler. How would I do this? Do I need to create a project, or can I just compile the source files? Can it even be done?
Since I'm completely new to C::B and to real windows programming but want to learn, I would really appreciate a detailed explanation, and if possible some background about the difference between DOS/Windows programming. (I guess that is probably outside the scope of this forum, so if someone could point me to the background I want)
Thanks

mariocup

  • Guest
Re: new-b
« Reply #1 on: October 04, 2007, 11:38:05 pm »
Hi,

you need a Codeblock project to compile your sources. Just check the wizards (New Project) to get a simple project.

BMB

  • Guest
Re: new-b
« Reply #2 on: October 04, 2007, 11:41:29 pm »
Hi,

you need a Codeblock project to compile your sources. Just check the wizards (New Project) to get a simple project.
????

What type of project? Console?

Offline AmR EiSa

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: new-b
« Reply #3 on: October 05, 2007, 12:01:01 am »
What type of project? Console?

yes and if u use printf (C) make language c or c++

BMB

  • Guest
Re: new-b
« Reply #4 on: October 05, 2007, 12:04:15 am »
I tried that on one of the programs (one without graphics. I assume graphics won't work. Am I right?). It came up with a lot of errors.

:: === Tic, Debug ===
D:\My Documents\CB\Tic\main.cpp:: In function `int main()':
D:\My Documents\CB\Tic\main.cpp:23: error: `clrscr' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:23: error: (Each undeclared identifier is reported only once for each function it appears in.)
D:\My Documents\CB\Tic\main.cpp:24: error: `_NOCURSOR' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:24: error: `_setcursortype' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:: In function `int posswin(int)':
D:\My Documents\CB\Tic\main.cpp:92: warning: unused variable 'pos'
D:\My Documents\CB\Tic\main.cpp:: In function `void player_first()':
D:\My Documents\CB\Tic\main.cpp:166: error: `gotoxy' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:178: error: `RED' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:178: error: `textcolor' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:179: error: `cprintf' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:: In function `void start_game()':
D:\My Documents\CB\Tic\main.cpp:209: error: `gotoxy' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:210: error: `RED' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:210: error: `textcolor' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:211: error: `cprintf' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:: In function `void check_draw()':
D:\My Documents\CB\Tic\main.cpp:222: error: `gotoxy' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:223: error: `RED' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:223: error: `textcolor' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:224: error: `cprintf' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:: In function `void draw_board()':
D:\My Documents\CB\Tic\main.cpp:236: error: `gotoxy' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:: In function `void put_X_O(char, int)':
D:\My Documents\CB\Tic\main.cpp:281: error: `gotoxy' undeclared (first use this function)
:: === Build finished: 18 errors, 1 warnings ===

Offline AmR EiSa

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: new-b
« Reply #5 on: October 05, 2007, 12:14:52 am »
in frist i can't help u with unknow code , but did u c/c++ book work with ansii ?

and graphics don't work
« Last Edit: October 05, 2007, 12:18:41 am by AmR EiSa »

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: new-b
« Reply #6 on: October 05, 2007, 01:32:49 am »
This program is written using outdated console functions which are not directly available from the MinGW/GCC compiler. You should consider dropping them for newer functionality.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: new-b
« Reply #7 on: October 05, 2007, 05:06:23 am »
The problem is not "outdated console functions", but more like "trying to use Borland extensions". I also started programming in Turbo C++ (version 3.0, though), and when I switched to DJGPP (yeah, I started using DJGPP, then MinGW) I missed those Borland extensions provided in conio.h. However, I got used to not using them. If you really want to see your programs working again, I recommend you checking this site for a conio implementation for MinGW. I'm not sure if it implements every single thing you used in your programs, but you could give it a try (I've never used myself, so be sure to read the documentation first).

Think about reading a good and recent C++ book, so you can learn what's really used today and how it's used. Trying to convert your programs to use standard C++ would be a good exercise.

Offline PsYhLo

  • Almost regular
  • **
  • Posts: 157
Re: new-b
« Reply #8 on: October 05, 2007, 07:23:18 am »
I tried that on one of the programs (one without graphics. I assume graphics won't work. Am I right?). It came up with a lot of errors.

:: === Tic, Debug ===
D:\My Documents\CB\Tic\main.cpp:: In function `int main()':
D:\My Documents\CB\Tic\main.cpp:23: error: `clrscr' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:23: error: (Each undeclared identifier is reported only once for each function it appears in.)
D:\My Documents\CB\Tic\main.cpp:24: error: `_NOCURSOR' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:24: error: `_setcursortype' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:: In function `int posswin(int)':
D:\My Documents\CB\Tic\main.cpp:92: warning: unused variable 'pos'
D:\My Documents\CB\Tic\main.cpp:: In function `void player_first()':
D:\My Documents\CB\Tic\main.cpp:166: error: `gotoxy' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:178: error: `RED' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:178: error: `textcolor' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:179: error: `cprintf' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:: In function `void start_game()':
D:\My Documents\CB\Tic\main.cpp:209: error: `gotoxy' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:210: error: `RED' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:210: error: `textcolor' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:211: error: `cprintf' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:: In function `void check_draw()':
D:\My Documents\CB\Tic\main.cpp:222: error: `gotoxy' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:223: error: `RED' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:223: error: `textcolor' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:224: error: `cprintf' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:: In function `void draw_board()':
D:\My Documents\CB\Tic\main.cpp:236: error: `gotoxy' undeclared (first use this function)
D:\My Documents\CB\Tic\main.cpp:: In function `void put_X_O(char, int)':
D:\My Documents\CB\Tic\main.cpp:281: error: `gotoxy' undeclared (first use this function)
:: === Build finished: 18 errors, 1 warnings ===

from these errors i thing you need this http://conio.sourceforge.net/ this is a library for
  • gotoxy
  • textcolor
  • _setcursortype
  • clrscr
  • _NOCURSOR
these are functions you use in your code :)

BMB

  • Guest
Re: new-b
« Reply #9 on: October 05, 2007, 10:14:58 am »
Thanks for the info. I might try that conio.h thing, but I get the impression that I am better off re-writing these. What libraries can I use? How do I know which are only TC specific and which are standard?