Hello Zack,

Thanks so much for looking into this.  You indirectly answered one of my 
questions -- it's unnecessary to create an xCode project just to build and run 
a simple .cpp file  (yay!!!).

Having not used Unix except for a very brief period in the early 80s when VI 
was a line editor, perhaps you or someone else following this thread can 
indulge a few novice questions.  I gather VI is better for creating a .cpp file 
than the textEdit app?  If so, why?  What is the process for building and 
running from the command line?

Thanks again and best regards.
Geoff

On Jul 5, 2011, at 6:08 PM, Zachary Kline wrote:

> Hi Jeff,
> Interesting.  I copied and pasted your program, exactly as given, from the 
> email to a vi editing session and compiled it from the terminal.  The output 
> was what you would expect, i.e. it worked correctly.
> I'm not sure why Xcode would give you a different result with such a simple 
> program, and am afraid I'm just learning to use it myself, so know very 
> little about it.
> Very confused,
> Zack.
> On Jul 5, 2011, at 2:34 PM, Geoff Waaler wrote:
> 
>> Greetings all,
>> 
>> I am getting started with C++ using XCode 4.0.2.
>> 
>> The following was created as a C++ command line tool.  The objective of this 
>> "main.cpp" code was to accept a n integer from the console and display it:
>> 
>> #include <iostream>
>> using namespace std;
>> 
>> int main() {
>>    int  num;
>>    cout << "Please enter an integer: ";
>>    cin >> num;
>>    cout << "Thanks for typing.  You entered: " << num << endl;
>> }
>> 
>> Upon running this code via command-r I receive the message that output was 
>> generated.  The log window appears to stop and prompt me as expected -- I 
>> see the following:
>> 
>> GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC 
>> 2011)
>> Copyright 2004 Free Software Foundation, Inc.
>> GDB is free software, covered by the GNU General Public License, and you are
>> welcome to change it and/or distribute copies of it under certain conditions.
>> Type "show copying" to see the conditions.
>> There is absolutely no warranty for GDB.  Type "show warranty" for details.
>> This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000
>> [Switching to process 10756 thread 0x0]
>> Please enter an integer: 
>> 
>> When I enter an integer (e.g. 9) the following text appears:
>> 
>> Please enter an integer: 9
>> Thanks for typing.  You entered: 60106
>> Program ended with exit code: 0
>> 
>> Initializing num (ie int num = 0;) causes the garbage to disappear , except 
>> that the initialized value is always displayed regardless what I enter in 
>> response to the prompt.
>> 
>> I tried building a unix executable and running it from terminal, but the 
>> results did not vary.  An item in Google suggested running debug in 
>> "standard debug" mode, but from what I can find this may no longer be 
>> applicable in xCode 4?
>> 
>> If anyone can offer a suggestion I would be most appreciative.  Perhaps 
>> there is another list that is mor appropriate for this type of query?
>> 
>> Best regards.
>> Geoff
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "MacVisionaries" group.
>> To post to this group, send email to macvisionaries@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> macvisionaries+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/macvisionaries?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "MacVisionaries" group.
> To post to this group, send email to macvisionaries@googlegroups.com.
> To unsubscribe from this group, send email to 
> macvisionaries+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/macvisionaries?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"MacVisionaries" group.
To post to this group, send email to macvisionaries@googlegroups.com.
To unsubscribe from this group, send email to 
macvisionaries+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/macvisionaries?hl=en.

Reply via email to