Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Epprecht

macrumors newbie
Original poster
Aug 13, 2005
8
0
Hi, I'm a student learning C++, new to macs and xcode. Here's my situation: I begin a new project, choose C++ tool from the Command Line Utility Group, then write the source code. I click the build and go button and it compiles fine but will not execute. I keep getting [Session started at 2005-11-07 00:42:23 -500.] or http://i3.photobucket.com/albums/y71/swissgnr/Picture1.png and thats it. A friend of mine who uses Xcode and does C++ cannot figure out why I keep getting this. I'm not sure if it is something I'm doing wrong or what. If anyone could help it would be much appreciated.
 

Whyren

macrumors 6502a
Epprecht said:
Hi, I'm a student learning C++, new to macs and xcode. Here's my situation: I begin a new project, choose C++ tool from the Command Line Utility Group, then write the source code. I click the build and go button and it compiles fine but will not execute. I keep getting [Session started at 2005-11-07 00:42:23 -500.] or http://i3.photobucket.com/albums/y71/swissgnr/Picture1.png and thats it. A friend of mine who uses Xcode and does C++ cannot figure out why I keep getting this. I'm not sure if it is something I'm doing wrong or what. If anyone could help it would be much appreciated.
Welcome to MacRumors Forums!

What is your code supposed to be doing? It appears as though it is running, but there are no I/O prompts.
 

Earendil

macrumors 68000
Oct 27, 2003
1,567
25
Washington
Post a code and I'll give a looksee. No Promises though, I'm no expert on C++ under OSX, but I want to be :D

~Earendil
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
That the 'Run' button is visible suggests your program isn't actually running in that screenshot - otherwise the button would say 'Terminate' and be a red stop sign.
 

Epprecht

macrumors newbie
Original poster
Aug 13, 2005
8
0
Here is a screenshot of my source code; http://i3.photobucket.com/albums/y71/swissgnr/source.png This program is one that I had earlier this year and completed. I've used two C++ compilers before called Cygwin and Dev++, both compile and execute the program fine. So, I'm not sure if the problem is with my code or I'm not doing something right in Xcode.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Try cleaning the project. Then quit Xcode, and recompile the project. Should work (I got this exact same error a few days ago also).
 

hopejr

macrumors 6502
Nov 10, 2005
310
0
New South Wales, Australia
I've been using Xcode for ages for Cocoa development and didn't know you could do what you're trying to attempt. I usually use the terminal ;)

Well, I just tried your code, and it works for me (using Xcode). Do you have problems with other projects?
 

Selivanov

macrumors newbie
Nov 7, 2005
9
0
Voronezh, Russia
I don't knkow - if it is a bug or something else, but... you need to output '\n' at the end of the line.
Try the following code in the first cout << ...
Code:
cout << "Enter the length of the block (in meters)..."[B] << endl[/B];
May be it is a flushing problem of the output stream...
 

I3AnThRaX69

macrumors newbie
Nov 14, 2005
2
0
Very Same Problem

Im having the very same problem with the xcode tools about trying to run the program. It just says "[Session started at 2005-11-14 21:25:27 -0700.]" and nothing happens, i even try to click RUN like thousands of times and it just sits there i tried to use the help file and that didnt help for anything, and I didn't notice anything that helped the other person about his problem. Im just new to programing and dont get anything but here is my .cpp file
//
// Program to convert tempurature from Celsius degree
// units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212 - 32)/100 + 32
//
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
// enter the tempurature in Celsius
int celsius;
cout << "Enter the tempurature in Celsius:";
cin >> celsius;

// calculate conversion factor for Celsius
// to Fahrenheit
int factor;
factor = 212 - 32;

// use conversion factor to convert Celsius
// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32;

// output the results (followed by a NewLine)
cout << "Fahrenheit value is:";
cout << fahrenheit << endl;

// wait until user is ready before terminating program
// to allow the user to see the program results
system("PAUSE");
return 0;
}
 

Laser47

macrumors 6502a
Jan 8, 2004
856
0
Maryland
I3AnThRaX69 said:
Im having the very same problem with the xcode tools about trying to run the program. It just says "[Session started at 2005-11-14 21:25:27 -0700.]" and nothing happens, i even try to click RUN like thousands of times and it just sits there i tried to use the help file and that didnt help for anything, and I didn't notice anything that helped the other person about his problem. Im just new to programing and dont get anything but here is my .cpp file
//
// Program to convert tempurature from Celsius degree
// units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212 - 32)/100 + 32
//
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
// enter the tempurature in Celsius
int celsius;
cout << "Enter the tempurature in Celsius:";
cin >> celsius;

// calculate conversion factor for Celsius
// to Fahrenheit
int factor;
factor = 212 - 32;

// use conversion factor to convert Celsius
// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32;

// output the results (followed by a NewLine)
cout << "Fahrenheit value is:";
cout << fahrenheit << endl;

// wait until user is ready before terminating program
// to allow the user to see the program results
system("PAUSE");
return 0;
}
I pasted it in my xcode and it worked.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
I'm pretty sure it's an Xcode problem, not a code issue. Have you tried cleaning the project, and/or relaunching Xcode?
 

csubear

macrumors 6502a
Aug 22, 2003
613
0
kainjow said:
I'm pretty sure it's an Xcode problem, not a code issue. Have you tried cleaning the project, and/or relaunching Xcode?

Also try running your binary from the terminal. Looks like xcode screwed up its i/o redirect.
 

Epprecht

macrumors newbie
Original poster
Aug 13, 2005
8
0
I have tried cleaning the project and reopening it and it didn't work. Maybe I did not install xcode properly or something. Also, how would I try running my binary from the terminal? I'm still not sure how to do many things with xcode. Thanks
 

Whyren

macrumors 6502a
I may have found your problem. Your project name in the first instance seems to be named "mow.cpp" so your executable ends in ".cpp"; this appears to confuse XCode. I tried naming my project similarly and it produced the problem you're having.
Rename your project w/o ".cpp", build and see if it works.
 

Epprecht

macrumors newbie
Original poster
Aug 13, 2005
8
0
Yay! First, thank you Whyren, it did work not including the .cpp to the filename. I was used to adding the .cpp but I'm learning. I3AnThRaX69, thanks for the alternative and thanks to everyone else for the help! This thread was a my first post on MacRumors: Forums after lurking around for quite a while and it's a good place. danke
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
I3AnThRaX69 said:
Im having the very same problem with the xcode tools about trying to run the program. It just says "[Session started at 2005-11-14 21:25:27 -0700.]" and nothing happens, i even try to click RUN like thousands of times and it just sits there i tried to use the help file and that didnt help for anything, and I didn't notice anything that helped the other person about his problem. Im just new to programing and dont get anything but here is my .cpp file
//
// Program to convert tempurature from Celsius degree
// units into Fahrenheit degree units:
// Fahrenheit = Celsius * (212 - 32)/100 + 32
//
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
// enter the tempurature in Celsius
int celsius;
cout << "Enter the tempurature in Celsius:";
cin >> celsius;

// calculate conversion factor for Celsius
// to Fahrenheit
int factor;
factor = 212 - 32;

// use conversion factor to convert Celsius
// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32;

// output the results (followed by a NewLine)
cout << "Fahrenheit value is:";
cout << fahrenheit << endl;

// wait until user is ready before terminating program
// to allow the user to see the program results
system("PAUSE");
return 0;
}
Seeing this first time, it won't work properly because system("PAUSE"); does not exist on Macs.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.