Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 11, 2008, 11:27 AM   #1
mrezzy
macrumors newbie
 
Join Date: Mar 2008
Xcode Command Utility Tool C++ HELP

Hi,

I need help compiling in the command utility tool for Xcode. When I compile my source file, everything works fine, but when I go and make changes to the CPP source file, the compile won't compile the changes. It instead, compiles the original source file [without all the changes]. Can anybody help me?

This is the process I use to compile:

1. select command utility tool C++
2. New Project
3. Open main.cpp
4. paste source code
5. compile

My laptop:
Macbook with Tiger
Xcode 2.5

----
here is the original source file:

Quote:
#include<iostream>
#include<iomanip>
using namespace std;

struct time
{
int month;
int date;
int year;
int hr;
int min;
int sec;
}part1,part2,part3;

int timeinfo()
{
cout<<setw(16)<<"Todays' date is:"<<endl;
cout<<setw(2)<<part1.month<<"/"<<setw(2)<<part1.date<<"/"<<setw(4)<<part1.year<<endl;
cout<<setw(16)<<"Your Time-in is:"<<endl;
cout<<setw(2)<<part1.hr<<"::"<<setw(2)<<part1.min<<endl<<endl;
cout<<setw(16)<<"Your Time-out is:"<<endl;
cout<<setw(2)<<part2.hr<<"::"<<setw(2)<<part2.min<<endl<<endl;
cout<<setw(25)<<"\n\nYour Total Work Time is: "<<setw(2)<<part3.hr<<"hrs"
<<setw(2)<<part3.min<<"min"<<setw(2)<<part3.sec<<"sec"<<endl;
};

int main()
{
int timein;
int timeout;
int total,count,totalseconds;
total=0;
count=0;

cout<<"Good Morning!"<<endl<<endl;
cout<<"This is a Payroll Program that records your total hours worked"<<endl;
cout<<"Please enter all your time in MILITARY Time Format"<<endl;
cout<<"12 AM = 00 hours"<<endl;
cout<<"Please refer to this chart:"<<endl<<endl;
cout<<"Regular Clock [AM]: 12 1 2 3 4 5 6 7 8 9 10 11"<<endl;
cout<<"Military Time [AM]: 00 1 2 3 4 5 6 7 8 9 10 11"<<endl;
cout<<"Regular Clock [PM]: 12 1 2 3 4 5 6 7 8 9 10 11"<<endl;
cout<<"Military Time [PM]: 12 13 14 15 16 17 18 19 20 21 22 23"<<endl<<endl<<endl;


cout<<"Enter today's month: "<< endl;
cin>>part1.month;

cout<<"Enter today's date: "<< endl;
cin>>part1.date;

cout<<"Enter today's year: "<< endl;
cin>>part1.year;
cout<<endl<<endl;
cout<<"Enter Time in hour[military time]: "<< endl; //timein
cin>>part1.hr;

cout<<"Enter Time in minutes: "<< endl;
cin>>part1.min;
part1.sec=0;
cout<<endl;


cout<<endl; //timeout
cout<<"Enter Time out hour[military time]: "<< endl;
cin>>part2.hr;

cout<<"Enter Time out minutes: "<< endl;
cin>>part2.min;
part2.sec=0;
cout<<endl;

// Calculations
timeout = (part2.hr*360) + (part2.min*60);
timein = (part1.hr*360) + (part1.min*60);

totalseconds=timeout-timein;

part3.hr=totalseconds/360;
totalseconds=totalseconds%360;
part3.min=totalseconds/60;
totalseconds=totalseconds%60;
part3.sec=totalseconds;

cout<<endl;

cout<<timeinfo()<<endl;

return 0;
}
and here is the updated source code i want to compile:

Quote:
#include<iostream>
#include<iomanip>
#include <fstream>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////

struct time
{
int month;
int date;
int year;
int hr;
int min;
int sec;
}part1,part2,part3; //part1=time in , part2= timeout, part3= total time

/////////////////////////////////////////////////////////////////////////////////////

int timeinfo() // displays timecard info at end
{
cout<<setw(16)<<"Todays' date is:"<<endl;
payroll<<<<setw(16)<<"Todays' date is:"<<endl;
cout<<setw(2)<<part1.month<<"/"<<setw(2)<<part1.date<<"/"<<setw(4)<<part1.year<<endl;
payroll<<setw(2)<<part1.month<<"/"<<setw(2)<<part1.date<<"/"<<setw(4)<<part1.year<<endl;
cout<<setw(16)<<"Your clock-in is:"<<endl;
payroll<<setw(16)<<"Your clock-in is:"<<endl;
cout<<setw(2)<<part1.hr<<":"<<setw(2)<<part1.min<<endl;
payroll<<setw(2)<<part1.hr<<":"<<setw(2)<<part1.min<<endl;
cout<<setw(16)<<"Your clock-out is:"<<endl;
payroll<<setw(16)<<"Your clock-out is:"<<endl;
cout<<setw(2)<<part2.hr<<":"<<setw(2)<<part2.min<<endl;
payroll<<setw(2)<<part2.hr<<":"<<setw(2)<<part2.min<<endl;
cout<<setw(25)<<"\n\nYour Total Work Time is: "<<setw(2)<<part3.hr<<"hrs"
<<setw(2)<<part3.min<<"min"<<setw(2)<<part3.sec<<"sec"<<endl;
payroll<<setw(25)<<"\n\nYour Total Work Time is: "<<setw(2)<<part3.hr<<"hrs"
<<setw(2)<<part3.min<<"min"<<setw(2)<<part3.sec<<"sec"<<endl;
cout<<"Do another time calculation? Enter Y or N:";
}

//////////////////////////////////////////////////////////////////////////////////////

int main()
{
ofstream payroll;
payroll.open("payroll.txt"); //write a file
int timein;
int timeout;
int total,count,totalseconds;
total=0;
count=0;

cout<<"Good Morning!"<<endl<<endl; // welcome messages
cout<<"This is a Payroll Program that records your total hours worked"<<endl;
cout<<"Please enter all your time in MILITARY Time Format"<<endl;
cout<<"12 AM = 00 hours"<<endl;
cout<<"Please refer to this chart:"<<endl<<endl;
cout<<"Regular Clock [AM]: 12 1 2 3 4 5 6 7 8 9 10 11"<<endl;
cout<<"Military Time [AM]: 00 1 2 3 4 5 6 7 8 9 10 11"<<endl;
cout<<"Regular Clock [PM]: 12 1 2 3 4 5 6 7 8 9 10 11"<<endl;
cout<<"Military Time [PM]: 12 13 14 15 16 17 18 19 20 21 22 23"<<endl<<endl<<endl;

char character; //For Y/N Do Loop
do //Begin Do Loop
{
cout<<"Enter today's month: "<< endl;
paroll<<"Enter today's month: "<< endl;
cin>>part1.month;

cout<<"Enter today's month: "<< endl;
payroll<<"Enter today's month: "<< endl;
cin>>part1.date;

cout<<"Enter today's year: "<< endl;
payroll<<"Enter today's year: "<< endl;
cin>>part1.year;
cout<<endl<<endl;
cout<<"Enter Time in hour[military time]: "<< endl;
payroll<<"Enter Time in hour[military time]: "<< endl; //timein
cin>>part1.hr;

cout<<"Enter clock in minutes: "<< endl;
payroll<<"Enter clock in minutes: "<< endl;
cin>>part1.min;
part1.sec=0;
cout<<endl;


cout<<endl; //timeout
cout<<"Enter clock out hour[military time]: "<< endl;
payroll<<"Enter clock out hour[military time]: "<< endl;
cin>>part2.hr;

cout<<"Enter clock out minutes: "<< endl;
payroll<<"Enter clock out minutes: "<< endl;
cin>>part2.min;
part2.sec=0;
cout<<endl;

// Calculations
timeout = (part2.hr*360) + (part2.min*60);
timein = (part1.hr*360) + (part1.min*60);

totalseconds=timeout-timein;

part3.hr=totalseconds/360;
totalseconds=totalseconds%360;
part3.min=totalseconds/60;
totalseconds=totalseconds%60;
part3.sec=totalseconds;

cout<<endl;

cout<<timeinfo()<<endl;
payroll<<timeinfo()<<endl;


}while((character != 'N' ) && (character != 'n'));

payroll.close();

return 0;
}
any help would be appreciated!

regards,

Eymon
mrezzy is offline   0 Reply With Quote
Old Mar 11, 2008, 01:18 PM   #2
toddburch
macrumors 6502a
 
Join Date: Dec 2006
Location: Katy, Texas
Send a message via AIM to toddburch Send a message via MSN to toddburch
Can you post a picture of your xcodeproj window? Looks like this:
Attached Thumbnails
Click image for larger version

Name:	Xcode001.png
Views:	34
Size:	62.4 KB
ID:	107399  
toddburch is offline   0 Reply With Quote
Old Mar 11, 2008, 02:25 PM   #3
sord
macrumors 6502
 
Join Date: Jun 2004
If you look at XCode's build errors, you can see that:
In timeinfo you don't have the payroll variable declared (probably want to use it as a parameter to the method) -- and you have 4 <s instead of 2.
Theres a warning because timeinfo should return an int, but returns nothing.
And theres a typo in main (paroll should probably be payroll).

If you look at the bottom right hand corner of XCode after doing a build, it shows how many build errors and warnings you have. You can click on that to show you the problems.

I took a screenshot (XCode 3) for you: http://home.earthlink.net/~valiantsoul/xcode.png
If your XCode is < 3, it won't show the actual errors/warnings in the editor, but you will still see the markers and part at the bottom right.
__________________
12" iBook 1GHz 768MB RAM 60GB HD Airport Extreme [sold and missed]
17" iMac G5 1.6GHz 768MB RAM 160GB HD [sold]
PowerMac Quad 2.5GHz G5 2.5GB RAM
sord is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Help with command line tool on xcode! noahgolm Mac Programming 5 Aug 19, 2010 08:18 PM
C++ Command line tool - Issue other CLI commands hiddenpremise Mac Programming 5 Jan 13, 2009 06:38 PM
what unix command line tools do you use most often? SHankara Mac Applications and Mac App Store 9 Mar 30, 2008 08:22 AM
Xcode 2 Freezes in C++ Command line tool CookieMook Mac Programming 7 Oct 1, 2006 09:39 PM
Help with embedding a command line tool within a Cocoa application? mrichmon Mac Programming 2 Feb 23, 2006 01:25 AM


All times are GMT -5. The time now is 07:45 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC