Click here to Skip to main content
15,913,722 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: One more link error __argc/__argv Pin
Christian Graus30-Aug-05 13:00
protectorChristian Graus30-Aug-05 13:00 
QuestionParent Window Pin
Nishad S29-Aug-05 18:36
Nishad S29-Aug-05 18:36 
AnswerRe: Parent Window Pin
Christian Graus29-Aug-05 18:43
protectorChristian Graus29-Aug-05 18:43 
GeneralRe: Parent Window Pin
Nishad S29-Aug-05 19:15
Nishad S29-Aug-05 19:15 
GeneralRe: Parent Window Pin
Christian Graus29-Aug-05 19:17
protectorChristian Graus29-Aug-05 19:17 
GeneralRe: Parent Window Pin
Jörgen Sigvardsson29-Aug-05 20:02
Jörgen Sigvardsson29-Aug-05 20:02 
GeneralRe: Parent Window Pin
John R. Shaw30-Aug-05 14:17
John R. Shaw30-Aug-05 14:17 
QuestionNeed Help (classes and .h files) Pin
SummoningDan29-Aug-05 18:06
SummoningDan29-Aug-05 18:06 
Ok to start things off i am a complete noob at programming, been trying to learn most of it myslef. Recently i made a property managment Database for the properties i own. I want to try and upgrade this program with implementing classes and Vectors. now im not sure what to do and how to transform it, i think the struct would go in the class in a .h file and the fuctions would go in the .cpp can someone please review the code below and give me a rough indercation of what to do.


----------------------------------------------------------------
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

struct propertyInfo
{
string address;
string suburb;
int price;
};

void displayProperty (propertyInfo property);
void getProperty(propertyInfo &property, int &);
void displayLibrary(propertyInfo properties[], int &);
void displayFile(propertyInfo properties[], int &);
void search(propertyInfo properties[], int &);
void saveproperty(propertyInfo properties[], int &numProperties);
int displayMenu();

const int MAXPROPERTIES = 100;

int main()
{

int numProperties = 0;
propertyInfo properties[MAXPROPERTIES];
propertyInfo property = {};
displayFile(properties, numProperties);

int choice = displayMenu();
while (choice!=0)
{
switch (choice)
{
case 1: search(properties,numProperties);
break;
case 2: saveproperty(properties, numProperties);
break;
case 3: displayLibrary(properties, numProperties);
break;
case 4: getProperty(properties[numProperties], numProperties);
break;
case 5: return 0;

}

choice = displayMenu();
}

system("pause");
return 0;
}

void getProperty(propertyInfo &property, int & numProperties)
{
cout << "\nEnter address: " ;
getline(cin, property.address);
cout << "Enter suburb: ";
getline(cin, property.suburb);
cout << "Enter price: ";
cin >> property.price;
cin.ignore();
cout <<"property: " << property.address << ", " << property.suburb << ", " << property.price << " added";
numProperties++;
}

void displayProperty (propertyInfo property)
{
cout << property.price << " " << property.address << " " << property.suburb ;
}

void displayLibrary(propertyInfo properties[], int &numProperties)
{
cout << endl;
for(int t = 0; t < numProperties; t++)
{
displayProperty(properties[t]);
cout << endl;
}
}

void displayFile(propertyInfo properties[], int &numProperties)
{
string FileName = "";
string Extension = ".txt";
cout << "Enter property filename: ";
cin >> FileName;

FileName = FileName + Extension;

//Convert the sting into a char pointer in order to pass it to open()
const char * TheFile = FileName.c_str();

ifstream fin;
fin.open(TheFile, ios::in);
if(fin.is_open())
{
while (numProperties < MAXPROPERTIES && !fin.eof())
{
getline(fin, properties[numProperties].address);
getline(fin, properties[numProperties].suburb);
fin >> properties[numProperties].price;
fin.ignore(); // ignore new line character left after reading int
numProperties++;

}

fin.close();
}
else
cout << "Could not open filename: " << FileName << endl;
}

void search(propertyInfo properties[], int &numProperties)
{
int searchamount = 0;
cout << "Enter Search amount ";
cin >> searchamount;
cout << endl;

for (int z=0; z < numProperties; z++)
{
if (properties[z].price < searchamount)
{
displayProperty(properties[z]);
cout << endl;
}
}
}

int displayMenu()
{
int choice =0;
cout << "\nMenu:\n";
cout << "1 - Property Search" <<endl;
="" cout="" <<="" "2="" -="" save="" property="" list"="" <<endl;="" "3="" list="" all="" properties"="" "4="" add="" a="" property"="" <<endl;
="" "5="" exit"=""

="" cout<<="" "enter="" menu="" choice="" ";="" cin="">> choice;
cin.ignore(1);
return choice;
}



void saveproperty(propertyInfo properties[], int &numProperties)
{
string fileName = "";
string Extension = ".txt";
cout << "Enter filename: ";
cin >> fileName;
cout << "Property details saved to the file: " << fileName <
AnswerRe: Need Help (classes and .h files) Pin
Christian Graus29-Aug-05 18:38
protectorChristian Graus29-Aug-05 18:38 
GeneralRe: Need Help (classes and .h files) Pin
SummoningDan29-Aug-05 18:51
SummoningDan29-Aug-05 18:51 
GeneralRe: Need Help (classes and .h files) Pin
Christian Graus29-Aug-05 18:54
protectorChristian Graus29-Aug-05 18:54 
GeneralRe: Need Help (classes and .h files) Pin
SummoningDan29-Aug-05 20:24
SummoningDan29-Aug-05 20:24 
GeneralRe: Need Help (classes and .h files) Pin
SummoningDan30-Aug-05 1:21
SummoningDan30-Aug-05 1:21 
GeneralRe: Need Help (classes and .h files) Pin
Christian Graus30-Aug-05 12:55
protectorChristian Graus30-Aug-05 12:55 
GeneralRe: Need Help (classes and .h files) Pin
SummoningDan30-Aug-05 17:37
SummoningDan30-Aug-05 17:37 
GeneralRe: Need Help (classes and .h files) Pin
Christian Graus30-Aug-05 17:40
protectorChristian Graus30-Aug-05 17:40 
QuestionError Pin
Member 216100429-Aug-05 17:36
Member 216100429-Aug-05 17:36 
AnswerRe: Error Pin
Barm29-Aug-05 17:48
Barm29-Aug-05 17:48 
Questionselect excel cells with automation Pin
Bayu Ardianto29-Aug-05 17:17
Bayu Ardianto29-Aug-05 17:17 
Questiondial a telephone number ,and play audio file Pin
sunnf29-Aug-05 15:54
sunnf29-Aug-05 15:54 
AnswerRe: dial a telephone number ,and play audio file Pin
Christian Graus29-Aug-05 17:14
protectorChristian Graus29-Aug-05 17:14 
QuestionError C2065 Pin
Member 216100429-Aug-05 15:44
Member 216100429-Aug-05 15:44 
AnswerRe: Error C2065 Pin
Christian Graus29-Aug-05 16:03
protectorChristian Graus29-Aug-05 16:03 
GeneralRe: Error C2065 Pin
Member 216100429-Aug-05 16:33
Member 216100429-Aug-05 16:33 
GeneralRe: Error C2065 Pin
Christian Graus29-Aug-05 16:36
protectorChristian Graus29-Aug-05 16:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.