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

mrezzy

macrumors newbie
Original poster
Mar 11, 2008
1
0
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:

#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:

#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
 

toddburch

macrumors 6502a
Dec 4, 2006
748
0
Katy, Texas
Can you post a picture of your xcodeproj window? Looks like this:
 

Attachments

  • Xcode001.png
    Xcode001.png
    62.4 KB · Views: 116

sord

macrumors 6502
Jun 16, 2004
352
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.