|
|
#1 |
|
c++ on mac os x
Wll I'm kinda new at c++ ..and even newer at using a mac....so here is my quetion:
How do you perform a c++ "clear screen" under mac os x?....under windows system("cls") should get the job done so I thought of using system("clear) but it returns me a "TERM no enviroment variable set" cya PD: I'm using xcode2 . |
|
|
|
0
|
|
|
#2 |
|
I am curious on why you are working in C++ on Mac. Unless you are working on UNIX code, you should probably focus on C/Obj-C.
Are you useing C++ for learning purposes? As to the Question... it sounds like you are looking for a console command. Could you send a snippet of code where you are using this? Max. Last edited by maxvamp; Jan 16, 2006 at 03:48 PM. |
|
|
|
0
|
|
|
#3 |
|
Sending a formfeed should clear the Terminal window. If you don't know how to do that, you should look up escape sequences.
|
|
|
|
0
|
|
|
#4 | ||
|
Quote:
Code:
#include <iostream>
int main(){
system("Open -a \"disk utility\"");
system ("Open -a terminal");
return 0;
}
So, to sum this up: Don't worry about this error. You will get this error only when you use this command in xCode. When you run the application you built as a normal command-line application (in which the terminal will be used) everything is going to work fine. Quote:
C++ and C are for Carbon applications Obj-C is for Cocoa.
__________________
Oramind: Articles, reviews Techlology and Art
If you don't like it, program it. Last edited by Soulstorm; Jan 16, 2006 at 04:27 PM. |
|||
|
|
0
|
|
|
#5 |
|
AFAIK the Xcode pseudo-terminal doesn't have these capabilities (or more precisely, I don't know and haven't found out what type of terminal it is supposed to be).
You can work around this issue by selecting you executable in XCode in the Groups & Files side bar, clicking Info and then the Arguments tab. Here add an environment varaible called TERM with the value xterm-color. You can play around with different terminal types, if you like. It won't clear your output though but if you might find a value of TERM that does (try Google). Obviously, not all escape codes are going to work, either, as these are also tied to the terminal type. The alternative is to run your executable from Terminal.app rather than through XCode, which should work as expected. Again, AFAIK, you can't set XCode to use Terminal.app for I/O. |
|
|
|
0
|
|
|
#6 | |
|
Quote:
In either case, I always keep the motto of "When in Rome....". jdrm could learn C++ on the Mac, but it is my belief that if he is looking to be the most efficient on the Mac platform, he would do well to learn the Obj-C flavor of an Object oriented C language . If jdrm is going after the marketable skill set, then C++ is a better one to pick, as he will be able to apply it to *NIX and Windows programming. Max. |
||
|
|
0
|
|
|
#7 | |
|
Quote:
__________________
Oramind: Articles, reviews Techlology and Art
If you don't like it, program it. |
||
|
|
0
|
|
|
#8 | |
|
Quote:
Ahh, You just hit directly my biggest complaint about OS X. I actually like the Cocoa framework better, but having to work with it with Obj-C and ( for me in any case ) it is a big pain in the butt. I am a C++ guy, and I have had some issues stemming from habit when trying to work in Obj-C. Carbon has in recent years been treated as the red headed step child by Apple and by the Book publishing community. This seems to be forcing the Obj-C language. Luckily, Obj-C++ is starting to come more into the Apple vernacular My ultimate concern is that, being a beginner, the original poster is not overwhelmed by the amount of knowledge needed, especially when trying to trying to move from one language to another. I guess the question for him ( or her ) is... What is your long term goals for coding ( only OS X, or multi-platform ) . Long and short... C++ is a good language to learn, but knowing what they plan on doing makes it impossible to determine what path is the best. On one other note, I just finished the book "Beginning Mac OS X Programming". This is an excellent book for people beginning Mac Programming. It covers Carbon and Cocoa, C and Obj-C, and a generally good bit of well rounded knowledge. It may be a bit light weight for someone with medium to advanced programming knowledge. BookPool.com has it for 50% off. Max. |
||
|
|
0
|
|
|
#9 | |
|
Quote:
), things should work quite well. Of course, using Cocoa almost guarantees that you can create a Universal Binary easily. System 6-style Carbon needs a lot of work to get things going.Objective-C++ would be great if the rest of the gcc suites--not just Apple's--had it. |
||
|
|
0
|
|
|
#10 | |
|
Quote:
Terminal control is very dependant on the underlying OS and platform. In a Unix environment (including OS X) nowdays you can be fairly certain that the underlying terminal will be emulating an xterm. This means that if you print the appropriate control codes to clear an xterm screen then it will probably work for you. In this case, the control codes would be printed by printf("\33[2J"); (\33 prints the "escape" character). As other posters have pointed out, the XCode console might not emulate an xterm and thus may not understand the above control codes. If this is the case then the above printf will not clear the XCode console, but will clear a terminal window when the application is run from the command line. Your original attempt - using system("clear"); will work if you are running in the terminal and the TERM environment in the terminal is set correctly (eg to "xterm"). This system(...) operation is trapping out of your program to invoke the command "clear". Although this would work it is very inefficient since it requires the creation of a new process (running program) to do a simple operation. Last edited by mrichmon; Jan 17, 2006 at 08:57 PM. |
||
|
|
0
|
|
|
#11 | |
|
Quote:
For reference, the \33[2J breaks down into
You can build up a fairly sophisticated interface just by printing the control sequences directly to move the cursor around, clear the screen and erase and print in various ways. However, you are much, much, much better off investigating and using a standard library to do this sort of thing. One of the most common libraries to use is the Curses library which you can google for. I'm not sure if Curses has a C++ binding. Under the covers, anything that controls the terminal is ultimately printing the control sequences to the terminal. Libraries like Curses provide easier ways for the programmer to work with the terminal. |
||
|
|
0
|
|
|
#12 |
|
I'm pretty sure intel recently released the beta for their Mac compilers and they have a C++ compiler, so C++ could be a better option than Obj-C as far as intel optimization is concerned, when it comes time.
__________________
The coolest calendar on iOS - zoomendar.com |
|
|
|
0
|
|
|
#13 | |
|
Quote:
|
||
|
|
0
|
|
|
#14 | |
|
Quote:
__________________
- weg |
||
|
|
0
|
|
|
#15 |
|
Look into using the ncurses library, it will give you a portable way to clear the screen on a variety of platforms.
|
|
|
|
0
|
|
|
#16 | |
|
Quote:
The jest of it is this. The Xcode Run Log is more like a Terminal emulator. Because of this, there are some C++ commands that won't work. The code will compile with no errors, as it should. These commands work fine when run using Terminal. Click here for a Terminal Quick Start Guide
__________________
Really? Really, really!
Last edited by Fender2112; Jan 19, 2006 at 05:05 PM. |
||
|
|
0
|
|
|
#17 | |
|
Quote:
|
||
|
|
0
|
|
|
#18 | |
|
Quote:
Think it also this way: If one learns C++, the move to OBJ-C is easy.
__________________
Oramind: Articles, reviews Techlology and Art
If you don't like it, program it. |
||
|
|
0
|
|
|
#19 |
|
What Apps to use for C++ ?
Ive been learning C++ for 4 months now at university but ive been using Visual Basics on Windows XP
So what apps would you recommended for The mac ? |
|
|
|
0
|
|
|
#20 | |
|
Quote:
![]() On a side note: Does anyone know what the future plans are for Code Warrior?
__________________
Really? Really, really!
|
||
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| Resolved: Any good kids games to run on an iMac G3 running Mac OS 10.1-10.4? | alexreich | PowerPC Macs | 10 | Feb 10, 2012 02:09 AM |
| Mac Os gone and only windows shows up, Help me. | Sarwanster | Windows, Linux & Others on the Mac | 2 | Sep 24, 2011 01:32 PM |
| Screen Flickering on iMac G3 DV after upgrade to Mac OS X | Coolmatt49 | PowerPC Macs | 3 | Jun 19, 2011 02:43 AM |
| Can I install Mac OS X on multiple hard drives?? | Cmd-the-World | Mac Pro | 4 | Feb 4, 2011 08:05 AM |
All times are GMT -5. The time now is 03:07 AM.






), things should work quite well. Of course, using Cocoa almost guarantees that you can create a Universal Binary easily. System 6-style Carbon needs a lot of work to get things going.
Really? Really, really!
Linear Mode

