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

I don't know about other compilers but Microsoft has already converted standard time_t to a 64-bit number unless you specifically ask for a 32-bit number

//
// extracted from time.h
//
#ifndef _TIME_T_DEFINED
#ifdef _USE_32BIT_TIME_T
typedef __time32_t time_t;      /* time value */
#else
typedef __time64_t time_t;      /* time value */
#endif
#define _TIME_T_DEFINED         /* avoid multiple def's of time_t */
#endif

So using _time64_t isn't necessary. Just use standard time_t and your program will be find.

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

I'm not much on linux either, but I think you can combine all that into one statement: g++ vector_jar_test.cpp marble.cpp will create the executable file a.out.

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

The errors you posted are compile-time errors, not link errors. So that lib files have not been processed yet.

did you include windows.h before including that header file?

#include <windows.h>
#include "ChaidInterface.h"
...
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The vector isn't expecting a pointer. Change the vector to this if you want pointers: vector<Shape*> shapes;

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

you can also use setw() to specify the width of the print field cout << left << setw(20) << "Number" << setw(25) << "Numerical Scores" << setw(15) << "Grade" You also will have to include <iomanip> header file for the above to compile.

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

It is global but only within the scope of the class. If you want to make it static then you have no other choice than to declare it globally as I showed you.

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

You are not listening -- I already explained that 6 hous ago in my post #3 to this thread.

As I alredy mentioned and posted you have to allocate memory for those pointers in that char*pointer[10] array. The way you have written it all 10 pointers point to the same address. What you need is for each pointer to have different, unique addresses. The only way to accomplish that is using the new operator.

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

you should not have to modify that header file. Just add that header file to the *.cpp program's includes, call the functions, and tell the compiler what *.lib file to use. You could use a pragma to do that in the *.cpp file #pragma comment(lib, "mylib.lib"); or add it to the project settings.

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

I finally finished it -- got 67%

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

I like the idea of being able to specify the number of rep points I could give someone. I'm more concerned about bad rep -- I rarely give out bad rep because I don't want to destroy their overall rep points. It would be like running over an ant hill with a bull dozer. If I could specify only 1 or 2 bad rep points instead of 21 I might be more inclined to give bad rep.

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

Thanks for your patience, but we cannot use "string" and "struct" yet.
.

replace string with character arrays and replace the struct with two arrays, one array of ints and the other of charcter arrays.

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

fgets() function appends '\n' to the end of the string, so you either need to strip it from the input string or not print '\n' (endl) in the output string.

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

I think first you have to understand how the 2nd system is going to display the values: If system 1 has 5.123 what is system2 going to do with it? should system1 send 5123, or just 5, or what?

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

you failed to implement everything I said before. Re-read my previous post and compare with what you posted. You are trashing your program's memory with that fgets() line

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

Ok, normally wouldn't do it but this thread is getting pretty long and you have tried pretty hard. Here is how I would code it.

#include <iostream>
#include <string>
using namespace std;

struct grades
{
    int score;
    string grade;
};
int lower_limits[10] = {
    80, 75, 70, 65, 60, 55, 50, 45, 40, 35
};
string letters[10] = {
    "A", "A-","B","B-","C","C-","D","D-"
};

int main()
{
    const int MAXGRADES = 10;
    struct grades theGrades[MAXGRADES];
    for(int i = 0; i < MAXGRADES; i++)
    {
        cout << "Enter score #" << i+1 << "\n";
        cin >> theGrades[i].score;
        // now find the grade
        for(int j = 0; j < 10; j++)
        {
            if(theGrades[i].score > lower_limits[j])
            {
                theGrades[i].grade = letters[j];
                break;
            }
        }
        if(theGrades[i].grade == "")
            theGrades[i].grade = "F";
    }
    for(int i = 0; i < MAXGRADES; i++)
    {
        cout << "score " << theGrades[i].score << " = " << theGrades[i].grade << "\n";
    }

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

That is a linker error

You are right about that

- you'd have to setup your project to compile linestorage.cpp.

Nope -- nothing to do with that. See my previous post.

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

lines 16, 17 and 18: too many loops and too many fgets() function calls. The while statement will read the entire file.

Also you can use retazce like that because its just an array of pointers that point to nowhere. You have to first read the line into a valid buffer, allocate space in retazce, then copy to retazce, like below

char oneline[255];
while(fgets(oneline, sizeof(oneline), pFile)!=NULL) { 
   retazce[line] = new char[strlen(oneline)+1];
   strcpy(retazce[line], oneline);
   line++;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

change the reference to a pointer and see if that solves the problem.

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

static class members have to also be declared globally just like any other global object

// in the *.cpp file
#include <iostream.h>
#include <conio.h>
#include "LineStorage.h"

LineStorage::vector <vector <vector<char> > > S;

void LineStorage::setchar(int l,int w,int c,char d)
{
    vector <char>::iterator it=LineStorage:: S[l][w].begin();
    LineStorage:: S[l][w].insert((it+c-1),d);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

if grade is declared as an int then you need to typecast it when printing it cout << (char)grade It might be cleaner if you had an array of grades similar to the scores so that you could figure out all the grades first and then print them in a nice tidy loop.

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

>>My mom was an English teacher

Great :) maybe she will clear that up for us (me).

>>What was your score mate?
I didn't finish it.

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

you won't find those functions in time.h because they are non-standard functions, as I previously said. You have to look them up at the Microsoft web site. Just use google and you will find them (just click that link).

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

That's crazy. "Four Yards Worth" shouldn't have an apostrophy. And there are other wrong answers too.

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

there is no such thing as an "obj-c" class. C language knows nothing about classes. Maybe you mean a structure object declared in a c translation unit (*.c program) ?

// *.cpp file
extern C int myint;

if you have a large group of objects

// *.cpp file
extern C
{
    int myint;
    // blabla
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

*mumbles something about find_last_of*

Of course :) perfect solution.

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

those error messages are correct. Did you look up those functions in msdn to see what are their parameters? If not, then you should do so. You have to be careful about those non-standard Microsoft functions. Microsoft declared many standard C functions depreciated, the c and c++ standards made no such statement. If you want to use the _s functions you need to also understand that other compilers don't support them. So if you turn in that assignment to your teacher and he/she doesn't use the same compiler then your program won't compile and you may get a lower grade.

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

If the string looks something like this: Dani Web 100 Then just use getline() to read the entire line, and start at the end of the string and back up until you find the first space, split the string at that point.

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

I came across this utube video while doing my modly duties on PFO. What an ingenious device that lets one man do the work of a hundred men.


http://www.youtube.com/watch?v=g658QgjFYt0&eurl=http://www.containerlift.ru/&feature=player_embedded

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

when you add the files to the project as I previously explained and you select Build --> Build Solution the IDE will compile all the *.cpp and *.c files then link the all together into one executable program. Its really not at all that difficult to do.

In the file that contains main() function you will probably have to declare functions in other files as extern, if you don't do that then the compiler will complain about undeclared functions

// main

extern int foo(); // located in another *.cpp file

int main()
{
    foo(); // call the function in another file
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 50 and 51: array numbers always begin with 0, not 1.

for(int i = 0; i < n; i++)
{
    for(int j = 0; j < n; j++)
    {
          num[i][j] = j+1;
   }
}

line 44: >>matrixPermute (temp);
This is a recursive function call, yet you always are passing the same value of temp which never changes in that loop. It looks like that function will be an infinite recursion, which will eventually crash and burn the program.

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

>>Is there a command in C++ that I could use to capitalize only the first letter and not the whole word?

No. You have to do that yourself. The toupper() function works on only one character.

Instead of all those gets(), you would just get input from the keyboard in one huge string at one time, then parse that string and turn the first letter of each word into capital letter

std::string line;
getline(cin, line); // get the entire line
// now parse the string and capitalize each word
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I've tried that before (putting files in different folders) with that compiler and vc++ 2008 express. It can be done, but a little tricky.

For *.cpp and *.c files: open Solution Explorer, right-click Source Files, then in the dropdown menu select Add --> New Filter. That will add a new folder under Source Files folder. Do the same with with the Header Files folder. After that you can add existing files to those new folders -- right click on the folder then select Add --> Existing Item then navigate to the items you want to add to that folder.

When you compile the solution you have to be careful about the location of the includes that are in those *.cpp and *.c files because for locally created header files they won't be in the same place as they would have been had you just put the source files directly in the Source Files folder.

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

how to do that will depend on the compiler, each one is a little different.

Do you mean you want to put the source files, such as *.cpp, *.c, and *.h, in different folders?

dvsConcept commented: very helpful +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>my biggest problem at the moment is how do I pass the pointer into the function when the pointer is pointing to a struct?

Do it the same as you would do with any other data object, such as a pointer to an int

void foo( Divison* pDiv)
{
  // blabla
}

int main()
{
    Division d;
    foo( &d );
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You might use a pure virtual base class and a vector of classes. Something like this might work.

class DrawingObject
{
...
    virtual void Draw() = 0; // implemented by subclass
};

class Circle : public DrawingObject
{
...
    virtual Draw() ; // implenentation of base class
};

class Rectangle : public DrawingObject
{
...
    virtual Draw() ; // implenentation of base class
};

// creation of this vector is not shown here
vector<DrawingObject> theList;

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	
	switch (message)
	{
		.
		.
		.
      case WM_PAINT:
            hdc = BeginPaint(hWnd, &ps);
            for(int i = 0; i < theList.size(); i++)
                  theList[i].Draw();
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Create a function w/c accepts as input the double numbers x1,x2,x3 and returns to the program the value of the average (x1+x2+x3)/3 as a variable parameter.


#include<stdio.h>
#include<conio.h>
main()
{

stdio.h and conio.h are both C header files, not c++. you posted this in the c++ forum -- is that the one you readlly want?

conio.h is a non-standard header file which is not supported by very many compilers, so you might as well just delete that line.

Next you need to declare some doubles double x1, x2, x3, x4, x5; csurfer pretty much outlined the rest of the things you have to do. If you are still confused then you will probably have to re-study your text book and do all the exercises at the end of each chapter.

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

>>and wont feel like counting out up to 800,000 characters to find out.
LOL :)

>>So how do i make the file pointer to the beginning of the file and clear all errors

infile.seekg(0, ios::beg);
infile.clear();

You should start reading about the various functions available to fstream class. Here is one good source.

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

Here is the output I got

1         George Washington          Fed   	4/30/1789	3/3/1797	2/22/1732	VA		12/14/1799	VA		1
2         John Adams                 Fed   	3/4/1797	3/3/1801	10/30/1735	MA		7/4/1826	MA		1
3         Thomas Jefferson           D/R   	3/4/1801	3/3/1809	4/13/1743	VA		7/4/1826	VA		1
4         James Madison              D/R   	3/4/1809	3/3/1817	3/16/1751	VA		6/28/1836	VA		1
5         James Monroe               D/R   	3/4/1817	3/3/1825	4/28/1758	VA		7/4/1831	VA		1
6         John Quincy Adams          D/R   	3/4/1825	3/3/1829	7/11/1767	MA		2/23/1848	MA		1
7         Andrew Jackson             Dem   	3/4/1829	3/3/1837	3/15/1767	SC		6/8/1845	TN		1
8         Martin Van Buren           Dem   	3/4/1837	3/3/1841	12/5/1782	NY		7/24/1862	NY		1
9         William Henry Harrison     Whig  	3/4/1841	4/4/1841	2/9/1773	VA		4/4/1841	OH		1
10        John Tyler                 Whig  	4/6/1841	3/3/1845	3/29/1790	VA		1/18/1862	VA		1
11        James K Polk               Dem   	3/4/1845	3/3/1849	11/2/1795	NC		6/15/1849	TN		1
12        Zachary Taylor             Whig  	3/5/1849	7/9/1850	11/24/1784	VA		7/9/1850	KY		1
13        Millard Fillmore           Whig  	7/10/1850	3/3/1853	1/7/1800	NY		3/8/1874	NY		1
14        Franklin Pierce            Dem   	3/4/1853	3/3/1857	11/23/1804	NH		10/8/1869	NH		1
15        James Buchanan             Dem   	3/4/1857	3/3/1861	4/23/1791	PA		6/1/1868	PA		0
16        Abraham Lincoln            Rep   	3/4/1861	4/15/1865	2/12/1809	KY		4/15/1865	IL		1
17        Andrew Johnson             Dem   	4/15/1865	3/3/1869	12/29/1808	NC		7/31/1875	TN		1
18        Ulysses S Grant            Rep   	3/4/1869	3/3/1877	4/27/1822	OH		7/23/1885	NY		1
19        Rutherford B Hayes         Rep   	3/4/1877	3/3/1881	10/4/1822	OH		1/17/1893	OH		1
20        James A Garfield           Rep   	3/4/1881	9/19/1881	11/19/1831	OH		9/19/1881	OH		1
21        Chester A Arthur           Rep   	9/19/1881	3/3/1885	10/5/1829	VT		11/18/1886	NY		1
22        Grover Cleveland           Dem …
rickster11 commented: Thanks, helped a bunch +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

For some reason ifstream doesn't work with that file. Change it to FILE pointer and it works ok

//    ifstream inPresFile("presfile.dat");
    FILE* inPresFile = fopen("presfile.dat", "rb"); // <<< THIS

    if (!inPresFile)
    {
        cout<<"File could not be opened"<<endl;
        exit(1);
    }

    heading();
    
    int counter = 0;
    //for (int counter=1; counter < 43; counter++)
    while( fread(reinterpret_cast<char *> (&presRecord),1, sizeof (presRecord), inPresFile))
    {
        ++counter;
        //nameField[0] = '\0';
        //inPresFile.read(reinterpret_cast<char *> (&presRecord),sizeof (presRecord));


        strcpy (nameField,presRecord.firstName);
        strcat (nameField," ");
        strcat (nameField,presRecord.lastName);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 10: that function gets the file size the hard and slooooow way. All you have to do is seek to the end of file then call tellg() to get the file size -- only two lines of code :)

If you want to leave that function as it is, then you will have to move the file pointer back to the beginning of the file and clear all errors before leaving the function. If you don't then the program won't be able to read the file any more.

>>But the bookFile character(c) is blank.
Look at the file with Notepad.exe (or some other text editor) and find the character your program should find. Is it a space?

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

post new code.

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

To take a line from Retired Army Gen. H. Norman Schwarzkopf, there isn't a nice way to kill the enemy (in this case an animal).

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

It's Ok. I know the rules.

Apparently not well enough to add code tags

[code=cplusplus] // your code here

[/code]

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

pass it as a parameter to DrawingARect() and to the drawing functions in your class.

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

your loop is doing too much work.

char codes[] = "qwertyuiop";

string dCode = "wtu";  // hard-code search value

for(int i = 0; i < dCode.size(); i++)
{
    for(int j = 0;  codes[j] != 0; j++)
    {
          if( dCode[i] == codes[j])
          {
              cout << codes[j-1];
              break;
          }
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome to DaniWeb. There are quite a few of us older people here now. Welcome to the gang :)

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

>>else if(currentChar == "" ) cout << " " << endl;

change that "" to " " (with a space between the quotes)

else if(currentChar == "" ) cout << " " << endl;
	else if(currentChar == ",") cout << "," << endl;
	else if(currentChar == ".") cout << "." << endl;
	else if(currentChar == "!") cout << "!" << endl;
	else if(currentChar == "?") cout << "?" << endl;

why not just shorten tat to this: else cout << currentChar << endl;

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

>>That's where the guards (the #ifdef stuff) are for right?

Nope. The guards prevent the same include file from being processed more than once. For example:

#include "element.h"
#include "element.h" // this one will be ignored

Your program had a different problem. The preprocessor attempted to process the line that used element *elm but class element had not been fully defined yet. With forward references the class doesn't have to be fully defined in order to declare a pointer to it.

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

you can't do xor operation on an entire array -- only one element at a time. msg[0] ^= generator;