Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you have the programming guide then what's the problem?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>but in visual studio 5.0 or newer u can make mobile applications only for windows os.isnt it?
Yes

>>wat abt symbian os?
That's an os ? :S But seriously, I don't know, never used it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what language is that?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can download the source code for the complete compiler from www.gnu.org :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

neither. Use Visual Studio 5.0 or newer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

when posting that much code you need to post all of it so that it will compile cleanly (unless that's the problem). main.cpp does not contain the include files and class Medicane is undefined.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't understand it either. All arrays are passed by refernce -- never ever by value. But passing a pointer is different than passing an array

int main()
{
   int x;
   int ay[10];

   foo(&x); // pass a pointer to some object
   foo(ay); // pass an array to the same function

}

The compiler will not complain about the above, but foo() will probably crash if it is expecting an array and main() passes a pointer to an int.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

that is a template and works with strings as well as integers.

int main()
{
    string a = "Hello";
    string b = "World";
    swap(a,b);
    cout << a << " " << b << "\n";
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What your tutor said was the same that that _Nestor said in his post. Re-read his post to see how to do that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe that car was almost out of gas and he was rushing to the next gas station that's about 100 miles away :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That's one of the best commercials I've seen in a long long time :) But I live in Budweiser country.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you'll prob never want to see my incode comments, LOL
.

If they look like your first post 3 years ago then your teacher may mark down your grades. Write for others as well as yourself.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

do you mean the difference between void foo(int *array) and void foo(int array[]); ??

The difference: nothing. They are identical, just two different ways of saying the same thing.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>i don't understand how am i to use cin instead of getline
You are confused. The getline() that you posted does use cin. Look closely at line 14. Your question/comment make me wonder if you even wrote that code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Replace() is the wrong method to use because you can't control what characters that get replaced in what positions. Here is another solution that I tested and works

CString m_VideoName = "hello world";
	int len = m_VideoName.GetLength();
	int i = 0;
	while( i < len )
	{
		// advance to the first non-space character
		while(i < len && (isspace( m_VideoName[i] ) || ispunct(m_VideoName[i])))
			++i;
		if( i < len )
		{
			// convert the character to upper case
			CString str = m_VideoName.Mid(0,i);
			str += toupper(m_VideoName[i]);
			str += m_VideoName.Mid(i+1);
			m_VideoName = str;
		}
		// advance to the beginning of the next white space character
		while(i < len && !isspace( m_VideoName[i] ) )
			++i;

	}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome to DaniWeb. When you think you have most of it done post a link to it in Website Reviews and people will make comments.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what part(s) of that do you know how to write? Break the problem down into smaller parts and it will be a lot easier for you to write. For example: to start off "Write a c++ program". To that much first by just writing the shell of main(). "reads from the keyboard" should tell you that you need to do that using cin from <iostream> header file. Only after you have that part working do you want to do some more of the rest. Write a little then compile and fix all errors/warnings. Then repeat.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you don't need to use the Replace method -- just simply index into the array

int i = 0;
int len = m_VideoName.GetLength();
while( i < len )
{
    while(i < len && isspace( m_VideoName[i] ) && ispunct(m_VideoName[i]))
       ++i;
    if( i < len )
        m_VideoName[i] = toupper(m_VideoName[i]);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try moving m3.h down below the other header files in the *.cpp files. Maybe your compiler just doesn't like it to be the first header file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What compiler are you using that produces the error? There is nothing wrong with that header file. You don't need to typedef that struct in C++ because structs are almost identical to classes. So all you need is this:

struct VE
{int maxnr;
 int n; 
 int *a; 
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 32: why are you opening the output file for every character read from the input file??? Its already opened on line 28 and that one is never closed, so line 32 attempts to open the same file for output twice, and that will fail.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

your are right and there is nothing you can do about it because of the way floats and doubles are stored in memory. wikipedia has a good article about that

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Please post the first 3 or 4 lines of the input file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I just compiled with Dev-C++ and you are right -- it does screw up. The data is not sorted. I again ran it 20 times with VC++ 2008 Express and it worked correctly every time.

Conclusion: Dev-C++ is broken. It is beta afterall :) Use VC++ 2008 Express to save yourself a lot of unnecessary headaches.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't recall ever watching the TV series, but that's probably why it wasn't on tv very long because no one else watched it either :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Wow I don't think I'll ever notice that. Thanks a lot!! You rule :)

You can easily find such error yourself by learning how to use your compiler's debugger :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have a couple problems

Vector::Vector(float array[], int size)
        {
            p = new float[size];
            for (int i = 0; i < size; i++)
                p[i] = array[i]; // << change size to i
            arraySize = size; // <<<<<<<<<<<< add this line
         }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

fin.seekp(ios::begin)
fin.clear();

>>Hope you have tried... SeekTobegin()
That is only for MFC CFile class. Not available to anything else.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The first time GenerateRandomNumber() returns 0 causes an infinite loop. Make it return a value from 1-10 instead of 0-9 by adding 1 to the result. randomNumber = rand() % 10 + 1;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its hard to believe that any teacher would give that assignment in a Programming 101 type into class.

You would probably have to write some sort of pattern recognition program, which is highly specialized and advanced type of programming. Not something that a newbe, or many oldtimers, could tackle.

Sounds like you had bettern drop that course like a hot potato.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can write DLLs or shared libraries that extend the functionality of a program, but beyone that the answer to your question is NO because C and C++ are not interpreted languages.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Is that possible
Yes it is, in fact its common for large programs to have hundreds of *.cpp files.

>>How can I achieve that?
The most common way is to create a header file and include it in each of the *.cpp files

// myfile.h header file
extern void func(); // function prototype
filename: File1.C
#include "myfile.h"
void main()
{
      funct(); //funct() from File2.C
}

Depending on the compiler you are using you will also have to compile each of the *.cpp files and link them together with all the required libraries. How to do that depends on your compiler.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is what I mean.

void load(string messages[], int keys[], int& numElements)
{
	int index = 0;
	int key  = 1;
	string message;
	while(index < MAX_SIZE && key > 0)
	{
		cout << "Please enter a key for number " << (index + 1) << ":\n";
		cin >> key;
		if(key > 0)
		{
			cout << "Please enter a message for number " << (index + 1) << ":\n";
			getline(cin, message);	
			cin >> message;		
			addMessage(messages, keys, numElements, message, key);
			index++;
		}
	}
	numElements = index;
}

>>But the problem is you need to put the delimiter '.' everytime you are inputing a message.
NO, that is not the problem and you don't have to do anything like that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

getline() returns *this or NULL if end-of-file.

This seems to work. I changed it to use all std::string and getline(). See this thread for the code to flush the '\n'

while(getline(inFile, title))
{
    getline(inFile, author);
    getline(inFile,call_number);
    call_number = call_number.substr(1);
    getline( inFile, status);
    inFile.ignore ( std::numeric_limits<std::streamsize>::max(), inFile.widen ( '\n' ) );
	
    cout << title << endl;
    cout << author << endl;
    cout << call_number << endl;
    cout << status << endl << "\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I did not see that V you speak of, Was it aired only over in the US ? (Im a brit). sounds good though, a little bit of human harvesting - nice! lol

may have been -- its a 5-hour or so movie on two DVDs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't do this because too many parameters
ofstream& operator<<(ofstream& out, float *p, int arraySize)

But you can put that pointer into a structure and make the operator output the struct

struct arr
{
    float* p;
    int arraySize;
};

ofstream& operator<<(ofstream& out, struct arr* p)
{
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>while(!inFile.eof())
wrong way to code that loop while( getline(inFile, title) )

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No special compiler needed. What you need is to use ODBC (there are other ways that are more specific to the database, but ODBC is common to them all)

google ODBC c++ classes and you will find several free ones.

I'd also suggest you read some ODBC tutorials and SQL tutorials You will have to learn the SQL language in order to make use of ODBC.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post CheckRandomNumber() and GenerateRandomNumber() because the problem is in one of those two functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>unless there are spaces in the message! i dont know how to fix that.
Don't try to fix it because that is not the problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What compile erros and warnings are you getting ? Did you correct them ? You can not just ignore warnings and expect the program to work right. For example: while(index < MAX_SIZE && key > 0) generates warning that key is used before initialized. Change it to 1.

in load() you need to flush the '\n' after entering the number cin.ignore(); after cin >> key;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

private variables can only be accessed by the class .

class A
{
private:
   int x;
public:
   void SetX(int n) { x = n; } // <<< this is ok
};

int main()
{
    A aobj;
    aobj.x = 0; // << error because not inside the class
}

protected is similar to private but can also be accessed by inherited classes

class A
{
protected:
   int x;
public:
   void SetX(int n) { x = n; } // <<< this is ok
};

class B : public A
{
public:
    void ShowX() { cout << A::x << "\n"; } /// this is ok
};

public can be accessed by anybody

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>are you saying i need to make numElements a call by reference parameter
yes -- see below

void addMessage(string messages[], int keys[], int& numElements, string message, int key)
{

you don't have to change load() at all.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Aren't you getting any compile errors ? I compile that code with VC++ 2008 Express and get an error that time() is undefined, and that is because you failed to include <ctime> header file.

This is the output I get

Array before Partitioning (20) -> 654 ,383 ,112 ,300 ,132 ,721 ,447 ,795 ,601 ,
115 ,335 ,726 ,395 ,386 ,542 ,624 ,292 ,555 ,713 ,930 ,
Pivot chosen is 930
Partitioning Done Array is now -> 112 ,115 ,132 ,292 ,300 ,335 ,383 ,386 ,395 ,
447 ,542 ,555 ,601 ,624 ,654 ,713 ,721 ,726 ,795 ,930 ,
Remember Pivot chosen was 930
Press any key to continue . . .

If you don't get that then tell me what compile your are using. Are you using MS-Windows, *nix MAC, or what?

>>nth_element (arr.begin(), (arr.end()-1), arr.end(), less<int>());

It isn't even necessary to specify that last parameter -- for your purpose just use the default nth_element (arr.begin(), (arr.end()-1), arr.end());

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Nope, can't do that either. Dev-C++ and minigw (I think that is its name) both use the *.a extensions, but the libraries must be compiled on the MS-Windows machine -- you can't just copy the lib from *nix to MS-Windows or any other operating system.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Oh btw, can someone also explain what this is 'srand ( time(NULL) );'. I read that I have to use it for some reason but I'm not too sure

srand() seeds the random number generator so that it will generate a different set of random numbers every time you run the program, providing you pass a different number to srand() each time. Most people just pass the return value from time() function because it is different everyt time you run the program. srand() should be called only once during the lifetime of the program, so you need to move it from GenerateRandomNumber() to near the beginning of main().

CheckRandomNumber() is incorrect. delete else return FALSE in that loop because it causes the loop to terminate after the first iteration. Just place a return FALSE; as the last line of that function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to pass numElements by reference in addMessage() function just like you did in load().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This requires two programs: 1) the program you want to install, and 2) and installation program. The installation program writes a signatrue and time_t object to the end of the application program then the application program reads this info on program startup to verify that the signature and time exists. This in no way guarentees any amount of security because the program can be changed by anyone with enough knowledge about c/c++.

The installation program does at least this:

#include <fstream>
#include <ctime>
using namespace std;

int main()
{
    char filename[] = "\\dvlp\\test1\\debug\\test1.exe";
    char signature[] = "Ronald McDonald:";
    time_t now = time(0);
    ofstream stream(filename, ios::app | ios::binary);
    if( stream.is_open())
    {
        stream.write(signature,strlen(signature)+1);
        stream.write((char *)&now, sizeof(time_t));
        stream.close();
    }
	return 0;
}

And the application program

#include <fstream>
#include <iostream>
#include <ctime>
using namespace std;

int main()
{
    char signature[] = "Ronald McDonald:";
    char temp[40]= {0};
    time_t t = time(0);
    // name of the application program
    ifstream in("..\\debug\\test1.exe",ios::binary);
    if( in.is_open() )
    {
        int pos = static_cast<int>(sizeof(time_t)) + strlen(signature) + 1;
        in.seekg(-pos, ios::end);
        in.read(temp, strlen(signature) + 1);
        if( strcmp(temp,signature) != 0)
        {
            cout << "Signature not found -- invalid installation\n";
            return 1;
        }
        in.read((char *)&t, sizeof(size_t));
        struct tm* tm = localtime(&t);
        cout << asctime(tm);
    }
    return 0;

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Another suggestion is replace the character array with std::string and you can keep those == comparison operators because std::string permits them.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

classes/structs must be terminated with a semicolon, which is missing at the end of hourlyEmployee_h