Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Okay, I was converting some of my old QuickBASIC programs over to C++, but I encounted a small problem. My QBASIC programs use the locate function a lot. Does C++ have anything like this?

QuickBASIC code:

Code:

print "Blah"
print "Blah"
print "Blah"

locate 2,2
print "XX"


This would give the output:

Code:

Blah
BXXh
Blah



Can C++ do something like that?
as far as i know, it can NOT using just ANSI code....

However, you CAN 'edit' the current line like so


Code:
std::cout << "This shouldn't show up";
std::cout << "\r"; //return cursor positiong to begging of the line
std::cout << "Hello, World!         \n"; //the extra whitespaces are to write over the remaining chars in the first output


to get keyboard input and move around a console screen you would need something like ncurses (or windows equivalent - check msdn.net or similar)
There's an include file called conio.c I believe. You will find it useful in your quest to use primitive graphics in C++.

EDIT: I uploaded them onto my site for your convenience:
conio.h
conio.c
Remember to include both files! Enjoy.
Thanks, guys.

And Jonathan, your website just says:

Quote:
for the good of all, gossipedia is no more


I have conio.h, but I'm not sure about .c
Ah yes. I'll take that down eventually. (It's a long story as to how it got there.)

Just save conio.c and conio.h to your include folder.
Foamy, do keep in mind that the code you write using conio.h will NOT be cross-platform portable, and will be limited to windows only. Other than that, have fun with it Wink

oh, and if you are using mingw and/or cygwin to compile, MAKE SURE you have the WINDOWS development packages and you include the windows.h in the compiler includes
Alright, I'll give it a try now.
If you want to make it crossplatform, use something called curses.c.

Kerm, I fixed your spelling. --Jon
Oh yeah I forgot conio is DOS-only. Silly me. Razz
Hehe. And thanks for the spellcheck. D:
Oh, foamy, another thing to watch out for with curses.c is that it isn't C++ (its C, hence the .c extension Wink ), and therefore won't be objectified or follow quite the same usage as, say, std::cout and such
Well, I've programmed in C, and I personally think it's preferable, perhaps from an ASM vs. BASIC type of standpoint.
Oh, alright.

Do any of you know any good online tutorials for use of these header files? I've found some around, but they usually just glance over one aspect of the headers. Do these headers come with any type of documentation?
I've never had to use an online reference for C++ before, but I've good experiences with this type of quick reference card in other languages.
Wow, sorry, I just caught that that was a link. Darn color-blindness...

But thanks, this pdf file looks great.
KermMartian wrote:
Well, I've programmed in C, and I personally think it's preferable, perhaps from an ASM vs. BASIC type of standpoint.


i love OOP sooo much - makes things so much easier to keep track of Very Happy
Ehhh, I personally preferred structured langs like ASM or BASIC.
KermMartian wrote:
Ehhh, I personally preferred structured langs like ASM or BASIC.


its ironic you list BASIC as an example of STRUCTURE - goto spaghetti anyone? Razz

OOP is structure, BASIC has absolutely no structure, and ASM has insanely minimal structure. OOP is just a way to describe more structure...so your "argument" contradicts itself...
It sure seems more logical to me to have:
Stuff:
more stuff
Stuff2:
continued stuff

than

stuff.morestuff.stuff2.additionalstuff...
KermMartian wrote:
stuff.morestuff.stuff2.additionalstuff...


i don't even want to KNOW where THAT came from Laughing

how about this?


Code:
class StuffMasterz {
   sometype Stuff {blahblahcodehere}
   sometype2 Stuff2 {blahblahcodehere}
}

myStuff = StuffMasterz();
myStuff.Stuff
myStuff.Stuff2

//or

myStuff* StuffMasterz();
myStuff* = new StuffMasterz();
myStuff->Stuff
myStuff->Stuff2


Also, where OOP really shines simplicity wise is when there are numerous objects. FOR EXAMPLE, a GUI. Instead of having to call specific functions and such, like


Code:
appendText(textBox1, myText);


its the much simpler, more logical


Code:
textBox1->appendText(myText)


it also makes it easier to read, and easier to find errors...

Plus, using gcnX as an example, it is much easier to make 'portable' code, as the classes can all be self contained.

Another advantage is being able to inherit other classses. For example, if i wanted to change how a socket class sends data, i could do something like...


Code:
Class mySocket: public realSocket {
   void send(data, len) {my send function code here}
}
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement