Posts: 6,419
Threads: 74
Joined: Mar 2002
Quote:How old is Turbo C++?
Depends on the version. Mine is v.3.1, which is from 1992 (
help -> about to find out)
Posts: 3,616
Threads: 287
Joined: Jan 2003
Oh, man...version 1.01, copyright 1990!
*Shivers*.
I'm abandoning it...although it's extremely useful for a quick reference...for instance, if you what info on any C++ common function/keyword, just type it in and you get full coverage on what it is...
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 6,419
Threads: 74
Joined: Mar 2002
Quote:Oh, man...version 1.01, copyright 1990!
*Shivers*.
I'm abandoning it...although it's extremely useful for a quick reference...for instance, if you what info on any C++ common function/keyword, just type it in and you get full coverage on what it is...
But you can get that in the other compilers+IDEs (MSVC, DevC++, GCC, DJGPP, ...)
Posts: 3,616
Threads: 287
Joined: Jan 2003
You get that in Dev-C++? How?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 6,419
Threads: 74
Joined: Mar 2002
Posts: 3,616
Threads: 287
Joined: Jan 2003
Uber-Cool, but it's not offline, and it doesn't have an index of keywords.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 90
Threads: 8
Joined: Aug 2003
Quote:I was (for practice) writing a string handler in C++, that should take characters from stdin, terminated by character-code 13 (Enter), and then print them to stdout. It compiles fine (Turbo C++), but in runtime, it takes the characters, but ends after user presses enter. It doesn't print them.
Here's my code:
Code:
#include <iostream.h> //for cout
#include <conio.h>
void outStr(char *strOut)
{
for (int i=0; i <= 255; i++)
{
if (strOut[i] != 0) //if we haven't reached the terminator
cout << strOut[i];
else
break;
}
}
void inStr(char *strBuf)
{
for (int i=0; i <= 255; i++)
{
strBuf[i]=getche(); //get the character
if (strBuf[i] == 13) //if user presses enter
{
strBuf[i]=0; //null-terminate
break;
}
}
}
What am I doing wrong?
(Note: Some compilers need main() to return an int...if yours does need this, just change the void main() line to int main() and add "return 0;" to the end of the main() function).
You're mixing c++ (cout) with a c library (conio, getche), they use differents i/o systems.
To turn your code into c++, you must replace strBuf[i]=getche() with cin >> strBuf[i]. Or if you want to turn into conio app, replace cout << strOut[i] with cprintf("%c", strOut[i]).
Posts: 6,419
Threads: 74
Joined: Mar 2002
Beware! cprintf is not portable. Use printf.
Posts: 3,616
Threads: 287
Joined: Jan 2003
Actually, xhantt, I fixed the problem by placing a cout << endl; between the two function calls in main(). The problem was that getche() didn't increment the x-character-position, so the cout call in outStr was printing right over what user types.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 4,307
Threads: 63
Joined: May 2003
Quote:...And...Turbo C++ doesn't support the string class....
what crap! Turbo C++ very well supports String Classes. Look up strng.h file(and no its not misspelled). Atleast TC++ v3.0 has it.
and iostream.h is a deprecated header so dont use it. Use iostream instead.