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

IMO C and C++ are poor languages for doing web stuff. It will be a lot simpler to use a language that is suited for that kind of programming.

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

Just as I thought -- you have to move that function into a *.cpp file.

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

Post your header file. I suspect you are putting executable code or declaring objects in it. You can't do that. If you want to put an integer in the header file then you have to declare it with the extern keyword so that the compiler knows to look in a *.c or *.cpp file for it. extern int foo;

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

Possibly lack of code guards is the problem.

#ifndef MYHEADER_H
#define MYHEADER_H

// other stuff here
#endif

[edit]what ^^^ said [/edit]

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

. "rt" isn't portable.

Whatever gave you that idea? True, text mode is the default, but there is nothing wrong with specifying 't' in the mode string. If there was then it would be in the c standards.

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

>> Carlist.Cost[i1]=
Should be Carlist[i1].Cost= ...

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

All versions, including the Express edition, has Windows Forms. To start a new project click File --> New --> Project --> CLR, then in the Templates window click Windows Forms Application

>>BTW, I am actually going to buy one of these versions but the pro edition is a bit pricy.

Don't bother -- just use the free Express version because it has the same compiler as all the other versions. The only difference between versions is all the other extra stuff you get, such as support for MFC.

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

The secret is using a great compiler's IDE, such as VC++ 2008 Express, and learning how to debug programs.

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

>> if (argv[2] = "SC")
You can't compare character arrays using the = operator like you do VB. Use strcmp() function prototyped in string.h header file -- or <cstring> if you prefer. if( strcmp(argv[2], "SC") == 0)

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

There is an error in the airport1.txt file on line 90 SYD BNE 07:30 1:00 getline() reads it in as SYD BNE07:30 1:00 -- missing the space between BNE and 07:30. I re-typed the line and the program continued to work from there until the next error, which was at the destructor

AllAirports::~AllAirports() {
    airports.~map();
}

You can't explicitly call a c++ class's destructor like that because it will crash your program.

ippomarley commented: shows amazing talent and experience +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Or just use XP zip compression - right click on the folder, and select Send To/Compressed Folder. XP wont unzip this thing, and neither will Python's zipfile module.

-- Paul

[sarcastic] Damn, how many gigabytes is this code. Trim it down to one million lines of code so you don't have to zip it. [/sarcastic]

Don't you two know how to read? This thread is 2 1/2 years old for God's sake. I really doubt anyone cares what either of you think about this topic.

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

I just got back from work and looked at the zip file you posted.

The program fails when function dummy() calls FileToString() because the file name (first parameter) contains the '\n' at the end of the filename, so the os can't find that file.

To correct that you will have to modify function Tokenize() to strip the character from the string.

vector<string> Tokenize(string data, char delimiter)
{
	vector<string> pieces;
	unsigned int a = 0;
	unsigned int b;
	while (true)
	{
		b = (unsigned int)(data.find(delimiter, a));
		if (b == string::npos)
			break;
                pieces.push_back( data.substr(a, b - a-1)); 
		a = b + 1;
	}
	pieces.push_back(data.substr(a));
	return pieces;
}
CppFTW commented: Thanks! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Can you zip up that file and post it here. I ran your program 2 million times without an error on a ReadMe.txt file.

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

Is the file more than 2 gig in size? Can you replicate the problem using the same file with a program that just calls those two functions?

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

I downloaded and tried to compile Turbo Vision with VC++ 2008 Express IDE (not using the makefile), but didn't have much luck. Tried using the makefile for vc compilers and that failed too, but did much better than when I tried it with the IDE solution I created.

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

Probably nothing wrong with Turbo Vision, but that's not the issue here. TVision is a library, not a compiler.

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

My favorite brand was Skippy until a few years ago because the peanut oil would float to the top in other brands. However now I have switched to Jif because it's not as dry tasting as Skippy, and spreads better.

peanut butter and jelly sandwitch -- yuuuuum :)

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

>>I was asked some interesting validation questions like:
>>Creamy or Crunchy? I answered crunchy (you have to be pretty deep American to even understand the question).

What does that mean by-the-way ? :)

Peanut Butter

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

why don't you just use one of the platform independent GUI 3d party libraries, such as wxWindows, GTK+, or QT. I think wxWindows and GTK+ will both work with VC++ 2008 Express (although I have not tried it). QT is its own IDE which works with nearly any 32-bit compiler.

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

>>you have to pass in an address

Not if you pass NULL.

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

So the implementation code for the class is in the application program and not the DLL? Sounds backwards to me, and when compiling the DLL it is not possible for the compiler to resolve the class references. I think you need to redesign something and put the class implementation code either in the DLL or a lib that the DLL can link with. c++ classes can be easily exported from a DLL just like any other function.

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

IMHO c++ for dummies is exactly that -- for dummies. There's an entire thread at the top of this forum about c++ books, you should read it.

For MS-Windows program all you need is a fundamental knowledge of C or C++ language. The win32 api does not require c++. Here is a good introduction.

UNICODE will not help you with superscripts or subscripts. To do that you have to use a different font, and required MS-Windows gui program. It can't be done with a console program.

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

>>I do not understand what is happening here

Microsoft completely rewrote CString to convert it from a c++ class in VC++ 6.0 compiler to a template in VC++ 2005 and later compilers. There were lots of changes to MFC, and CString was just one of them. Consequently you may have to rewrite parts of your programs to conform to the new version of MFC.

colmcy1 commented: Thanks for your help +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

how about this: return (d-1) < 0 ? North : d-1; No need for the mod operator.

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

The above code works right ??? Then whats the problem ? Why isn't this thread marked solved ?

Because the OP has not posted any code or made any other comments.

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

>> while (infile) {
>> for(int i = 0; i < 900; i++) { // NOTE for i < 900 this is

Don't you see a problem with that code? What will happen if the file only contains 10 lines? Or 901 lines? There is no need for that for loop. Instead, just use variable i as a counter to index into arrays.

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

Moved to C forum because it is a C program, not c++.

>>fflush(stdin);
Non-standard use of fflush(). There is no standard way to flush the input stream, and fflush() is only defined to flush output streams to the file on disk (e.g. your hard drive).

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

Here is one way to do it -- uses a vector of structures instead of individual arrays.

#include<iostream>
#include <sstream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;

struct person
{
    string name;
    float weight;
    string location;
    string color;
};

//inside main
int main(void)
{
    vector<person> people;
    string wt;
    person p;
    ifstream in("data.txt");
    while( getline(in,p.name,',') )
    {
        getline(in,wt,',');
        p.weight = (float)atof(wt.c_str());
        getline(in,p.location,',');
        getline(in,p.color);
        people.push_back(p);
    }
//
// now just display all the data in the vector
//
    vector<person>::iterator it = people.begin();
    for(; it != people.end(); it++)
    {
        cout << (*it).name << " "
            << (*it).weight << " "
            << (*it).location << " "
            << (*it).color << "\n";
            
    }

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

>>is there a difference between call by reference and pass by reference??
No. They both mean the same thing.

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

>>values.erase (values.begin());
That should erase the entire array.

Here is one way to print all the integers in the array

for(int i = 0; i < values.size(); i++)
   cout << values[i] << "\n";

Here is another way using an iterator

vector<int>::iterator it = values.begin();
for( ; it != values.end(); it++)
   cout << *it << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 4: move it up above liine 1

line 13: for (int Hour=1; Hour <= 24; Hour++)

That is wrong. Arrays are numbered from 0 to (and including) 23, so it should be written like this: for (int Hour=0; Hour < 24; Hour++) line 15: Emp = Cust/20 + 3;

Cust is an array, so it can't be divided. Maybe what you want is to index into the array: Emp = Cust[Hour]; line 16 has similar problem as line 15. You can use the mod operator on an array. if( Cust[Hour] % 20 == 0)

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

but the memory has not been allocated, so if you try to modify it the resulting behaviour is undefined.
.

The problem is NOT that memory was not allocated for the string (actually it was), but that the string resides in (probably) read-only memory, depending on how the compiler chooses to handle it. Its never advisable to try and modify string literals.

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

You might want to put code guards in that header file to prevent the problem you describe.

#ifndef POINTS_H
#define POINTS_H
struct Points {
int xCoordinate; 
int yCoordinate; 
int zCoordinate;
}; // end of struct Points definition
#endif
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I assume you want to pass the entire array to that function, then don't specify the array size. I'd also pass the element number that you want used in the sprintf() call.

void DisplayPoints(Point point[], int index){ 
    sprintf(xCoordinateText,"%.0f", point[index].xCoordinate);
    BasicFunctionsCode.render2DBitmapText(1080, 100, font, xCoordinateText);
} // end of DisplayPoints
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You could go to your CONTROL PANEL --> Edit Options and uncheck this option box. Other than that there is little that we can do about it.

you can allow other members to send you email messages.
[ ] Receive Email from Other Members

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

I tried to compile it with vc++ 2008 express and got other errors. Must be some header files missing -- I have no idea how to correct them.

1>c:\dvlp\test2\test2\debug\msado15.tlh(2375) : error C2059: syntax error : '<L_TYPE_raw>'
1>c:\dvlp\test2\test2\debug\msado15.tlh(2375) : error C2238: unexpected token(s) preceding ';'
1>c:\dvlp\test2\test2\test2.cpp(27) : error C2065: '_RecordsetPtr' : undeclared identifier
1>c:\dvlp\test2\test2\test2.cpp(27) : error C2146: syntax error : missing ';' before identifier 'pRstAuthors'
1>c:\dvlp\test2\test2\test2.cpp(27) : error C2065: 'pRstAuthors' : undeclared identifier
1>c:\dvlp\test2\test2\test2.cpp(30) : error C2065: 'pRstAuthors' : undeclared identifier
1>c:\dvlp\test2\test2\test2.cpp(30) : error C2228: left of '.CreateInstance' must have class/struct/union
1> type is ''unknown-type''
1>c:\dvlp\test2\test2\test2.cpp(30) : error C2065: 'Recordset' : undeclared identifier

<snip>

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

>> while (a != password)

Just for completeness, the above line should be written like this: while( password[0] != a ) That will remove the error, but not the logic of why you would want to code something like that. What about all the other characters the user typed?

If you want to compare the password you type with some pre-determined password then do something like this:

char password[31] = {0};
do
{
    cout << "Enter password\n";
    cin.getline(password, sizeof(password));
} while( strcmp(password, "abcdefg") != 0);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Probably not more than one in a thousand could name more than a couple of the MEPs we sent there last time.

Its like that here too. Very few American's can name the people in our Congress and Senate. Sure I know the names of a few, but all 600+ people?

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

If you post something in the wrong forum, just hit the "Flag Bad Post" blue link and request a mod to move it to somewhere else. We realize people are not perfect and sometimes make mistakes. You will not get any grief from any of the moderators if you ask us to move your thread, unless of course you want it moved to an inappropriate forum.

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

Now I understand, the problem is when you press F5 to start debugging. The Ctrl+Z sets some flags in cin that have to be cleared in order to get cin.get() or cin.ignore() to work properly.

cin.clear();
    cin.sync();
    cin.ignore();
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I used VC++ 2008 Express and it worked for me (see bitmap in my previous post).

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

And how, prey tell me, do you expect to enter your name and grades without a console window? What did you expect to see? Below is what I see when I run the program

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

Ctrl+F5 does not produce the eof signal the program is looking for. EOF is produced with Ctrl+Z key combination.

>>when I compile in release mode and run the exe it opens it in debug mode (or the same as the command line when you run as debugging)

Its supposed to do that because its a console program. That's a console window you see, not a debug window.

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

variable password is only a single character, which means it will accept only one character. If you want it to accept many more characters then declare it as an array of characters, or a std::string object, like this: char password[255] = {0}; . That lets you type up to 254 characters as the password.

[edit]^^^ I'm too late :) [/edit]

tux4life commented: But your info is excellent! +7
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post a small example program that has the problem you describe because I don't quite understand what you are talking about.

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

You should read the forum rules before posting, otherwise you will probably get into trouble. This is a feedback forum, as the title of the forum suggests. You will find rules specific to each forum at the top of the forum, like this:

Our Community Feedback forum is the place for DaniWeb site announcements, comments, and feedback..

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

>>I thought the discussion forum was for suggestions.
It is -- but you didn't post a suggestion. Geek's Lounge is where you can post silly and/or off-topic stuff. About the only time you will get kicked off there is if you post technical support questions, profanity, porn, advertisements, or flame someone.

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

continue program exception in the catch block.

void foo()
{
    cout << "foo() is throwing an excetption\n";
    throw 1;
}

int main()
{
    try
    {
        foo();
    }
    catch(...)
    {
        cout << "Exception caught\n";
    }
    cout << "Ending program\n";
}

Output is this:

foo() is throwing an excetption
Exception caught
Ending program
Press any key to continue . . .

[edit]And what ^^^ said. He beat me to it. Oh well, that happens sometimes.[/edit]

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

You can execute another program on PPC the same way you do it on a PC. CreateProcess() win32 api is one way. Remember, PPC does NOT have a command prompt, so system() is not available (as I recall). There is also no such concept as current working directory or change directory. There are directories on PPC, but there is no way to change the current working directory of the program.

Also be careful where you put files. If you have to cold boot the ppc device the file system gets reinitialized to the manufacturer's default. Files stored on extra memory device are unaffected by cold boot.

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