I have figured out. Still not sure why its doing what its doing. Once I do figure out that I will post a solution as a reference for others.

Hey everyone,
I was attempting to get the lastmodified file from a folder, and to do so I used File.listFiles() method which is returning a null pointer exception even though the folder is not empty.

I had this piece of code working about two days ago and I am not sure what changed since. I have looking java docs and I have realized that File.listFiles() will return a null if the arbitrary path is not found. But in this case the path does exists and as I mentioned it did work two days ago.

The for loop (has comment besides it) is the one that returns NPE.

Any hints or even any alternate methonds are appreciated.

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;

/*------------------ util imports ------------------------------*/
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Iterator;

/*------------------- SAX Parser Imports ------------------ */
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.SAXParser;
import org.xml.sax.SAXException;
import org.xml.sax.Attributes;

public class ReadXMLFile extends DefaultHandler
{
    private String temp = " ";
    Transaction transaction = new Transaction();

      void ReadErrorFile() throws IOException, SAXException, ParserConfigurationException
      {
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm;ss");

             String directory = "C: / Users //hbhasin/Documents/Error/";
             File ErrorFile = new File(directory);
            String Er_FileName = " ";

            long LastModifiedFile = Long.MIN_VALUE;
            File choice = null;

             File[] files= ErrorFile.listFiles(new FileFilter()
            { 
                 @Override
                 public boolean accept(File file)
                {
                   return file.isFile();
                }
            });

             for(File file : files) //this for loop returns NPE
             {
                  if(file.lastModified() > LastModifiedFile)
                  {
                      choice = file;
                      LastModifiedFile = file.lastModified();
                      Er_FileName = file.getName();
                  }
             }
         }

I guess that's one way. I was thinking of modulating two tasks (even though both tasks are to read two different files) and definitely making things more complicated then they should be.

thanks for pointing that out James.

How do I close this post?

Hi guys,
I am confused on how can I access a same class reference object , that is created in class ReadInoiceFile, and be accessed in ReadErrorFile.

To be more specific:
I have a class called Transaction

And then I have a class called ReadInvoiceFile.
And finally I have a class called ReadErrorFile.

So if I create a reference object of Transaction in ReadInvoiceFile and use the mutator method setOrderNumber to set a value of a variable called OrderNumber, how can I get access to that value in class ReadErrorFile.

Because if I create a reference object of Transacton in ReadErrorFile and try accessing OrderNumber I get a new copy which initially will be null.

Here is code snippet. I hope my question makes sense and thanks for any help.

public class Transaction
{
    private String InvoiceNumber ; 
    private String OrderNumber;

    public Transaction()
    {
        InvoiceNumber = " ";
        OrderNumber = " ";
    }

    public void setInvoiceNumber(String InvoiceNo)
    {
        this.InvoiceNumber = InvoiceNo;
    }

    public void setOrdrNumber(String OrderNo)
    {
        this.OrderNumber = OrderNo;
    }

    public String getInvoiceNumber()
    {
        return InvoiceNumber;
    }

    public String getOrderNumber()
    {
        return OrderNumber;
    }

    public class ReadInvoiceFile
    {
        Transaction transaction = new Transaction();

        public void ReadInput()
        {
            transaction.setOrderNumber("123AF");
        }
    }

    public class ReadErrorFile
    {
        //this would create complete new object
        Transaction transaction = new Transaction();

        public void getResults()
        {
            //this would print out null
            System.out.println(transaction.getOrderNumber());
        }
    }
}

Actually I found out the event log and yes there is an error. I believe it has to do with the way I am using InstallShield. If anyone can help me in showing how to add installshield to visual studio project, I would appreciate it.

thnank you

Thanks for replying lolafuertes. The target machine is a 32 bit and I compiled the program to run on 32 bit. And I also tried excecuting the program as an administrator. But neither of those actions have helped me.

Where in the system can I find the application log?

Thank you

Hi guys,

I am facing some issues trying to deploy my application developed in c# in visual studio.
I created a setup/.exe using InstallShield for visual studio 2012 with all the required files for the project included.
The target machine where I want to deploy this application is running windows 7 embedded and I just installed .net framework 4.5 on the machine (required for the application).

But when I click on .exe on the target machine, the system gets busy for few seconds but then nothing comes up.
The application is created in c# using windows form, so a form should come up but nothing actually comes on the target machine.

The target machine does not have visual studio and I would like to keep it that way. I also tried to play with the project configuration and see if there are any dependencies like dll but I am not able find any such thing on visual studio 2012 menus.

Please someone help me, by explaining me in steps what do I need to do make the executable run on a target machine.

Thank you

Hi guys,

I am facing some issues trying to deploy my application developed in c# in visual studio.
I created a setup/.exe using InstallShield for visual studio 2012 with all the required files for the project included.
The target machine where I want to deploy this application is running windows 7 embedded and I just installed .net framework 4.5 on the machine (required for the application).

But when I click on .exe on the target machine, the system gets busy for few seconds but then nothing comes up.
The application is created in c# using windows form, so a form should come up but nothing actually comes on the target machine.

The target machine does not have visual studio and I would like to keep it that way. I also tried to play with the project configuration and see if there are any dependencies like dll but I am not able find any such thing on visual studio 2012 menus.

Please someone help me, by explaining me in steps what do I need to do make the executable run on a target machine.

Thank you

Quoted Text Here

Why are you doing all that crap with tokens, fseeks, and stuff?

What's wrong with:....

Because this is how my text file looks:
1013 Richmond Ave ("this is Address1")
2034 Downtown Ave ("this is Address2")
Package
0

When I use tokenizer, it does all the work for me. In other words, with tokenizer "Address 1" gets stored in variable Address 1, "Address 2" gets stored in variable Address 2 and so on.
But with the method you showed me. this is the output I will get:
1013
Richmond
Ave
2034
Downtown
Ave
...
In other words every word gets stored separately.

Thank you every one for your suggestions. I looked into my program more carefully and rewrote some stuff and it has started to work but I have another (smaller) problem.

My issue is: I have a text file as such:

Address 1
Address 2
Package
0
Address 3
Address 4
Package
1

My program reads the first para (i.e. till 0) but does not read any further. I tried a do while loop but that did not make any difference. How else should I approach this.

I have rewrote the definition.c (for readfile) file. Here is my code again:

//FunctionDefinition.h file

#include "DeliveryServices.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char ReadFromFile()
{
    FILE *ReadFrom;
    char *buffer;
    char *tokenizer;
    unsigned long  fileLength;

    ServiceSlip PackageSlips;

    ReadFrom = fopen("datafile","r");

    if(!ReadFrom)
    {
        printf("Error opening file \n");
    }
    else
    {

    fseek(ReadFrom,0,SEEK_END);
    fileLength = ftell(ReadFrom);
    fseek(ReadFrom,0,SEEK_SET);
    }
    buffer =  (char*)malloc(fileLength+1);
    if(!buffer)
    {
        printf("Errom allocating memory");
    }
    fread(buffer,fileLength,1,ReadFrom);

    //printf("%s \n",buffer);

    tokenizer = strtok(buffer,"\n");
    strcpy(PackageSlips.PickUpAdd,tokenizer);

    tokenizer = strtok(NULL,"\n");
    strcpy(PackageSlips.DropOffAdd,tokenizer);

    tokenizer = strtok(NULL,"\n");
    strcpy(PackageSlips.ItemType,tokenizer);

    tokenizer = strtok(NULL, "\n");
    strcpy(PackageSlips.PriorAssign,tokenizer);

    printf("%s \n",PackageSlips.PickUpAdd);
    printf("%s \n", PackageSlips.DropOffAdd);
    printf("%s \n",PackageSlips.ItemType);
    printf("%s \n",PackageSlips.PriorAssign);

    fclose(ReadFrom);

return 0;
}

//main file
#include "DeliveryServices.h"
#include <stdio.h>
#include <string.h>

int main()
{   
    FILE *ReadFile;
    char lineRead;

    ServiceSlip  PackageSlips;

    ReadFromFile();

return 0; 
}

Thanks for all your help guys.

Hello everyone,
I am sort of new in C programming and since I programmed mostly in C++, I may have some mix up on my program which is giving me some errors. I have written a small code , in modular fashion i.e. I have split the .h, definition.c , and main.c files.
The program currently has only one function and all that does is read from a text file. My problem is when I compile each file separately I get the error: 'Undefined reference to ReadFromfFile()" (Note: ReadFromFile is a function defined in definition.c and I get this error when I compile the main.c file)
And when I compile the definition.c file I get the error 'Undefined reference to main'.
And when I compile all my files together as such: gcc DeliveryServices.h DeliveryServices.c main.c -o Servrices: I get the error 'Segmentation fault(core dumped)'.

Please someone point me out what am I doing wrong and how can I fix it.

Thank you.
//Header File

#ifndef DeliveryServices_H
#define DeliveryServices_H

#include <stdio.h>
#include <string.h>

 struct DeliveryServices{
                        char* ItemType;
                        char* PickUpAdd;
                        char* DropOffAdd;
                      };
                      typedef struct DeliveryServices ServiceSlip;
#endif   

//Definition File

#include "DeliveryServices.h"
#include <stdio.h>
#include <string.h>

char ReadFromFile()
{
        FILE *ReadFrom;
        char lineRead;

        printf("Hello");
        ReadFrom = fopen("datafile.txt","r");
        while(fgets(lineRead,120,ReadFrom))
        {
                printf("%s",lineRead);
        }
return 0;
}

//Main.c

#include "DeliveryServices.h"
#include <stdio.h>
#include <string.h>

int main()
{       
        FILE *ReadFile;
        char lineRead;

        ServiceSlip  PackageSlips;

        ReadFromFile();
        //PackageSlips.ItemType ="Package";
        //printf("%s",PackageSlips.ItemType);

return 0; 
}

Hello everyone,

This is my first program in C and I have ran into weird issue. I am implementing a simple server & client program in C.

From my main() in client I call a send_message() function which I believe binds with server and sends the message to the server side.

The function proto type for send_message is: int send_message(int Port_num, char*input)
where Port_num is for port number to connect to and
input: is a user input.

For a test I tried printing the user input as such send_message(3100,"HELLO"). This prints Hello in the send_message function

BUT, if I instead get a user input and try pass it to the function, I do not get an output.
This is how I am passing the user input

char id;
scanf("%d",&id);
send_message(3100, &id);

I have pasted my complete code here as well. Thank you for any input.

server.c

#include <stdio.h>
#include <netdb.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "functions.h"

#define STR_SIZE 4000

int PORT;

void* server_thread_func(void *arg) 
{ 
    const int Size = 64;
    int Array[Size];
     char buf[STR_SIZE];
    unsigned int addr_len;
    char serverport[STR_SIZE];
    char input[10];
    int id =0;
    int rv, val, sockfd, totbytes;  
    struct sockaddr_in their_addr;
    struct addrinfo hints, *servinfo, *p;

    val = 1;
    sprintf(serverport, "%d", PORT);

    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_DGRAM;
    hints.ai_flags = AI_PASSIVE;
    if ((rv = getaddrinfo(NULL, serverport, &hints, &servinfo)) != 0) 
    {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
        return (NULL);
    }

    for (p = ...

Hi, I am reading from a text file and stored it onto a string variable. Now I want to split the string and I tried looking it up on the web and found the strtok () function but that only works on a char type.
Here is my code snippet:

[code]

include
include "Stack.h"
include
include

using namespace std;

int main()
{
Stack list;
ifstream ReadFrom;
string line;

(getline(ReadFrom, line));[color=#FF6666]
split = strtok(line.c_str(),",.( )") // this does not work.[/color];
[/code]

Can some one give me an idea on how to accomplish this. Note: variable line has to be string type unless there is another way to read whole line from a text file.

thanks.

I am trying to do some arithmetic operation on a stack but I am little confused on how would I implement it.

For instance I have a statement:
add(multiply(2,3),4) which is equal to 2x3 = 6 + 4 = 10.

If I place this on the stack, it would look something like this:

)
4
)
3
2
(
multiply
(
add

My question how would I implement the above function here. In other words what should I do to make the program interpret the paranthesis in the right way, i.e. if you pop out 4, then 3, and then 2, the program multiplies 2x3 and the result + 4 not something else.

Thanks.

Hi guys,
Please can someone explain me how would I split a string into groups.
In other words, I have a string of numbers, as such:

123456789
I am supposed to store them in linked list nodes as such:
node 1: 1
node 2: 2345
node 3: 6789

I was thinking to do something like get the length of the string.
In this case: 9
Divide by 2 and store in variable div ( in this case div = 4)
Then mod length/2 and store in var mod( in this case mod = 1)
Then I am stuck thinking how would I store in to nodes 1, 2, 3 accordingly.

Would really appreciate any help.
Thanks.

D.I.C Head
**

Joined: 22 Oct, 2007
Posts: 51

[IN]
My Contributions

I am little confused here. So please help me.
I am given a txt file in the following format

110001 + 123500
......

I need to read these numbers into the source file, do the addition and then print the result.

My approach was to use a for loop to read a character at a time until an operator such as '+' is found. Store that number into a var1, then continue reading after the operator symbol '+' until new line is approached. Store that number into var2.
Then add var1+ var2.

But what will be my parameters for for loop. I mean
for (i = 0; i <= ? ; i++);

Appreciate your help guys.

I finally realized that I can use a temp variable to replace the word (I dunno what was I thinking until now!) But now I don't know how will I put the replaced word back into the sentence.
I mean, for example: I have a sentence ( teh disability documents....) where I want to replace 'teh' with 'the', now after replace this word how do I put it back into the sentence. Here is my code:

[code]

include
include
include

using namespace std;

string ReplaceErr(string, string, string);

int main()
{

ifstream insert;
ofstream output;

string Line, WordToRep, RepWith, ReadLine; 

insert.open("test.txt");

if(insert.fail())
{
    cout<<"File failed to open"<<endl;
    }
    //while(!insert.eof())

    getline(insert,ReadLine);
    cout<<ReadLine<<endl; //ReadLine will store the whole line read from the file

    cout<<"Please enter the word to be replaced."<<endl;
    cin>> WordToRep;

    ReplaceErr(ReadLine, WordToRep,RepWith);

system("Pause");
return 0;
}

string ReplaceErr(string RL, string W2R, string RW) //RL = ReadLine, W2R = WordToReplace, RW = ReplaceWith
{

    int position;
    string newWord; //temporary variable to store the word to replace with

    if((position = RL .find(W2R,0)) != string::npos)
    {
      cout<<"The word to be replaced:"<<W2R<<"was found."<<endl;
      }

      cout<<"Please enter the word to replace with."<<endl;
      cin>>RW;

      newWord = W2R;
      W2R = RW;

return RL;
}
[/code]

Thanks.

Ok I am almost done with this program except for the replace part. Here is my code so far:

[code]

include
include
include
include

using namespace std;

int main()
{
ifstream insert;
ofstream output;

string lineread; //line read  from the text file
char* search; //the word to be searched
char* replace; //the word to be replaced
int position;

insert.open("test.txt");

if(insert.fail())
{
    cout<<"File failed to open"<<endl;
    }

    //while(!insert.eof())
    {
      getline(insert,lineread); 
      cout<<lineread<<endl;//test to see if it prints the right text file
      }

      cout<<" Enter the word to be searched."<<endl;
      cin>> search;

      if((position = lineread.find(search,0)) != string::npos)
      {
        cout<<"The word:"<<search<<": was found"<<endl;
        cout<<"Replace this word with"<<endl;
        cin>>replace;

        cout<<lineread<<endl;

}
system("PAUSE");
return (0);
}
[/code]

Can you give some idea as to how can I replace the word with the new word.
This is what I was thinking to do but not really able to implement it.
1) My variable that stores the word to be searched is a pointer variable.
2) So if I could using the address of the variable I could put in a new word in that place.
Am I thinking it the right way? Either way please let me know how would I implement it.
Thanks.

[QUOTE=VernonDozier;978931]If the program simply reads in a file and replaces all instances of "dog" with "cat" or something, and writes it to a new file, I see no need to actually STORE the contents of the file in memory. Get a line from the ifstream and read it into a string. Replace all instances of "dog" in that line with "cat". Output the revised line to the ofstream. No need to store anything as far as I can tell.

If you decide you DO want to store the lines in an array, your main problem is the problem of not knowing how many lines there are in advance. Solve it by either:

[LIST=1]
[]Go through the file and count the number of lines, size your string array to that size, then open the file again and go through it line by line, substituting.
[
]Decide on a maximum number of lines in the file and make that the size.
[]Guess the size ahead of time, resize as you go through the file if your guess is incorrect.
[
]Use a vector instead of an array, in which case this is all done for you.
[*]Use something besides an array or vector (i.e. linked list) that avoids the overhead and guesswork of resizing.
[/LIST][/QUOTE]

Thats an interesting point of view. I guess I wasn't thinking the right way. Thanks for the idea, I may try that way.

I am trying to write a program in which a big text file is read and then user searches for a word and replaces it with another word. To implement this I was thinking to store the file read into an array since that would the easiest way to implement it (as far as I Know) and then compare each element with the word to be searched and when found replace it.
Here is my code:

[code]

include
include
include

using namespace std;

int main()
{
ifstream insert;
ofstream output;

string lineread;

insert.open("test.txt");

if(insert.fail())
{
    cout<<"File failed to open"<<endl;
    }

    while(!insert.eof())
    {
      getline(insert,lineread);
      cout<<lineread<<endl;//test to see if it prints the right text file
      }

system("PAUSE");
return (0);

[/code]

As you can see I have used a string variable to store the file being read but I want it to be stored in array which I don't understand how to implement.
I thought of using pointer arrays or better dynamic arrays but I am not able to implement it. Also I have looked up the pop and stack functions but I haven't been taught that so I am not very sure to use them.

Besides that any help is appreciated

Thanks guys. Davidoria's method worked out. But I am confused. Why would not using reference as I did earlier is not working.

From what I understood from my course, is I am sending the reference value of street to St_address and I am manipulating the street variable which should change the St_address variable as well.
And then I was trying to call the St_address in the main().

Please explain where am I going wrong.

Thanks.

Hi, I am trying to write an address book. The problem is: in my class declaration I declared a mutator.
In the implementation, I am asking the user to enter his address, city, state and zip.
So my prototype void set_add(string, string, string, int).
In other words I am trying to set the address, city, state, and zip variables to the one entered by the user. To implement this I am using reference.

But no matter what I put in as arguments while calling from main, I keep getting the error: variable 'variable' not declared.

Here is my code for clarity:

[code]
/**Header**/

ifndef addressType_H
include
include
include

using namespace std;

class addressType
{
private:
string St_address;
string city, state;
int Zip;

public:
addressType(string, string, string, int);//default constructor;
void show_add();//accessor
void set_add(string&, string&, string&, int&);//mutator

};

endif

/****Implementation*****/

include "addressType.h"
include
include
include

using namespace std;

addressType::addressType(string street, string cit, string st, int zip)
{
street = "9803 Summer Breeze Dr.";
St_address = street;
cit = "Pearland";
city = cit;
st = "Tx";
state = st;
zip = 77584;
Zip = zip;

}

void addressType::show_add()
{
cout<<St_address<<endl;
cout<<city<<","<<state<<endl;
cout<<Zip<<endl;

return;

}

void addressType::set_add(string &street, string &cit, string &st, int &zip)
{
cout<<"Enter street address."<<endl;
cin>>street;

cout<<"Enter your city."<<endl;
cin>>cit;

cout<<"Enter your state."<<endl;
cin>>st;

cout<<"Enter the zip code."<<endl;
cin>>zip;

return;

}

/**main()**/

include "addressType.h"
include
include

using namespace std;

int main()
{
addressType Avi("9803 Summer Breeze", "Pearland", "Tx", 77584);
Avi.show_add();
Avi.set_add(St_address, city, state, Zip);[COLOR="Red"]//what will be my arguments here that would ...

Hi, I declared and implemented a print() function in a class. But when I call this function it is giving me an error: which says that function does not take 0 arguments. But what should my arguments be.

I have posted the part of the code for more specification.
Thanks.

[code]
/****class header**/

class addressType
{
private:
string St_address;
string city, state;
int Zip;

public:
void print_add(string, string, string, int);
void get_add();
void set_add(string, string, string, int);
addressType();
~addressType();
};

endif

/*****implementation of print & set function*/

void addressType::set_add(string street, string cit, string st, int zip)
{

St_address = street;
city = cit;
state = st;
Zip = zip;

print_add(St_address, city, state, Zip);

return;

}
void addressType::print_add(string str, string Cit, string St, int Z)
{
cout<<"Address: "<<str<<endl;
cout<< Cit <<","<<St<<endl;
cout<<"Zip: "<<Z<<endl;

return ;

}

/**** main()****/
int main()
{
addressType Avi;
Avi.get_add();
Avi.print_add(); [COLOR="Red"]//error C2660 function does not take 0 arguments.
I am trying to print the user's address here.[/COLOR]

return 0;

}

[/code]

I am writing a program in which a print function takes in users' street address(string), city (string) , state (string), zip(int).
What will my return be for this function?

My code snippet is this:
[code]
string addressType::print_add(string str, string Cit, string St, int Z)
{
cout<<str<<endl;
cout<< Cit <<","<<St<<endl;
cout<<"Zip: "<<Z<<endl;

return ;//what should I return here?

}
[/code]

Thanks.

Solved it.

I was able to solve the error.
The problem was with the return type of the print_add() function. I changed it from string to void and the error got resolved.

But this leads me to a question, which I will ask in a new thread.

Hi I am writing a address book program that is giving a run time error. Please if someone can compile and check this error, and then explain/ show me how can I resolve it. I am pasting my code in parts here as well as attaching the files.

Also please someone explain me, how can I print the user input address in the main(). I mean what should my argument be for the print_add() when I call it in main().

I really appreciate your help.
Thanks.

[code]
/**Header file*****/

ifndef addressType_H
include
include
include

using namespace std;

class addressType
{
private:
string St_address;
string city, state;
int Zip;

public:
string print_add(string, string, string, int);
void get_add();
void set_add(string, string, string, int);
addressType();
~addressType();
};

endif

/***Implementation section*/

include "addressType.h"
include
include
include

using namespace std;

addressType::addressType()
{
St_address = "9803 Summer Breeze Dr.";
city = "Pearland";
state = "Tx";
Zip = 77584;

}

void addressType::get_add()
{

cout<<"Enter your street address."<<endl;
cin>> St_address;

cout<<"Enter your city."<<endl;
cin>> city;

cout<<"Enter your state."<<endl;
cin>> state;

cout<<"Enter your zip code."<<endl;
cin>> Zip;

set_add(St_address, city, state, Zip);

return ;

}

void addressType::set_add(string street, string cit, string st, int zip)
{

St_address = street;
city = cit;
state = st;
Zip = zip;

print_add(St_address, city, state, Zip);

return;

}

string addressType::print_add(string str, string Cit, string St, int Z)
{
cout<<"Address: "<<endl;
cout<< Cit <<","<<St<<endl;
cout<<"Zip: "<<Z<<endl;

return 0;

}

addressType::~addressType()
{}

/**Test program****/
// Address Directory.cpp : Defines the entry point for the console application.
// ...

Thanks, I knew I was forgetting some simple command but was not sure about it.

Please can someone show me how would I create a file using fstream
that would take the contents from another existing file and user input sentence.
for example:
I have file1 with some contents
The user inputs a sentence
Now I want to create a file using streams that has contents of file1 and sentence.

My possible coding

[code]
ofstream output;
output.open("file2.txt");
output<<file1 + sentence<<endl;
output.close();
[/code]

To me something in the code does not seem right.

Thanks, I actually figured out most of the stuff.
But I have some problem in my code. In the main(), I am trying to print the sales figure, but instead it is printing the address of the sales array. How can I resolve this without using pointers.

Once again,
Thanks.

My code
[code]

include "stdafx.h"

//#ifndef Salesperson_H
//#define Salesperson_H

include
include

using namespace std;

class Salesperson
{
public:
Salesperson(); // default constructor
~Salesperson();//destructor;

 Salesperson(double , double , double , double );//constructor 

void getSales(); //function to get 4 sales figures from user

void setsales(int , double );

void printsales();

void ReadFile();

void EditFile();

private:
double sales[4]; // array for quarterly sales figures.

};

Salesperson::Salesperson()
{
sales [0] = 0.0;
sales [1] = 0.0;
sales [2] = 0.0;
sales [3] = 0.0;

}

Salesperson::Salesperson(double quart1, double quart2, double quart3, double quart4)
{
sales [0] = quart1;
sales [1] = quart2;
sales [2] = quart3;
sales [3] = quart4;

}

void Salesperson::getSales()
{
int quarter;
double sales;

cout<<"Please input the the quarter number of the year."<<endl;
cin>> quarter;

cout<<"Please enter the sales of this quarter."<<endl;
cin>>sales;

setsales(quarter, sales);

return;

}

void Salesperson::setsales(int quart, double sales)
{

if(quart == 1) 
    sales[0] = sales;

if(quart == 2)
    sales[1] = sales;

if(quart == 3)
    sales[2] = sales;

if(quart == 4)
    sales[3] = sales;
    sales= sales [0] + sales [1] + sales [2] + sales [3];

return;

}

Salesperson::~Salesperson()
{}

void Salesperson::printsales()
{
cout<<"The total annual sale of the year was: $"<<sales<<endl;

return;

}

void ...

I have an assignment to implement a salesperson class.
Here is the layout I got from prof.
My questions are typed in red between function prototypes.

Any help is appreciated.
Thanks.

[code]

cClass Salesperson
{
public:
Salesperson(); //default constructor
[COLOR="Red"]// I know that a default constructor is suppose to set the values by default but how would I do this implementation for this constructor. I mean what would this constructor set the value for and how.
[/color]

~Salesperson(); // destructor

Salesperson(double q1, q2, q3, q4);

void getsales();
[COLOR="Red"][COLOR="Red"]// how would I use this function
[/color]

void setsales(int quarter, double sales);
[COLOR="Red"]//And how would I use this function[/color]

void printsales();

void ReadFile();

void EditFile();

private:
double slaes[4];//quarterly sales figures
};

[/code]