mitrmkar 1,056 Posting Virtuoso

The declaration only is not enough, so ...

// in ConjVector.cpp

// initialize enMemoria to some value ...
int ConjVector::enMemoria = 0;
mitrmkar 1,056 Posting Virtuoso

The code is too big to paste here so if you want a copy of it email me at vs49688@yahoo.com.au and ill email you a copy.

An alternative is to zip the project and post it as an attachment.

mitrmkar 1,056 Posting Virtuoso

Just related to the while() loop you have devised

while( jump == true )
{
    newy += gravity;
    
	if( newy > FLOOR_Y )
    {			
        newy = FLOOR_Y;
        jump = false;
        break;
    }
}

if you look at it closely, you'll see that it actually can be written as follows

if( jump == true )
{
    newy = FLOOR_Y;
    jump = false;
}
mitrmkar 1,056 Posting Virtuoso

I meant that you were misusing the assignment operator = there

if(jump = true)  // sets 'jump' to 'true'
while( jump = true ) // sets 'jump' to 'true'

instead, to check whether jump is true , use ...

if(jump == true) 
// or ...
while( jump == true )
mitrmkar 1,056 Posting Virtuoso

Since you have printVector(vector<T> & x) pass by reference ... printVector( x );

mitrmkar 1,056 Posting Virtuoso

One obvious little error ... if( jump = true )

William Hemsworth commented: Well spotted :) +3
mitrmkar 1,056 Posting Virtuoso

When I add default constructor to bigInt this problem is solved

OK, that problem is presumably solved.

but object n is not created accurately and I got runtime exception while accessing n.
What is my fault?

I'm guessing that you are using the pointer value uninitialized/unallocated. Couldn't you change that to a simple: unsigned value; You might also post the actual code that's giving you the error.

mitrmkar 1,056 Posting Virtuoso

I dereference them once to get access to LOD, but this doesn't seem to work. Why not?

Dereferencing was actually missing ... i.e.

if( (*(visualEntity.begin() + i))->LOD == wantLOD){
mitrmkar 1,056 Posting Virtuoso

Maybe I should: FILENAME* filePtr = new FILENAME; and then filePtr->SetFullPath(fname); and then files.push_back(*filePtr) Does that sound right?

That would leak memory because push_back() invokes the copy constructor of FILENAME i.e. you would not be storing the new'ed object anywhere, instead use simply ...

FILENAME file;
file.SetFullPath(fname);
files.push_back(file);
mitrmkar 1,056 Posting Virtuoso

Your code probably should be doing what the comment there already says (without any iterator(s))...

else // it is a regular file, so push this onto our list
{
	fname = path + "\\" + ffd.cFileName;

        // assuming you have a FILENAME object ...
	aFILENAME.SetFullPath(fname);

        // now at to the end of the list ...
	files.push_back(aFILENAME);
}
mitrmkar 1,056 Posting Virtuoso

You've gotten a bit confused about how to use the CreateWindowEx() function, the following should work ...

hList = CreateWindowEx(
    WS_EX_CLIENTEDGE,
    "ListBox", // the window class here 
    "Caption text ...", // needs WS_CAPTION style in order to be shown
                        // .. see below
    WS_CAPTION | WS_CHILD | WS_VISIBLE | WS_VSCROLL,
    10, 10, 100, 200, 
    hwnd,
    (HMENU) IDC_LISTBOX1,
    GetModuleHandle(NULL),
    NULL);
mitrmkar 1,056 Posting Virtuoso

Try replacing the line PaintRoutine(hwnddc, GetPixel(hDC, pt.x + x, pt.y + y), 1, 1, 1 + x, 1 + y); with SetPixel(hwnddc, x, y, GetPixel(hDC, pt.x + x, pt.y + y));

mitrmkar 1,056 Posting Virtuoso
...
double CelsiusToFahrenheit(double c);
...
int main()
{
...
}

double CelsiusToFahrenheit(double c) ; // <- remove the semicolon
{
	return (9.0 / 5.0 * c + 32);
}
mitrmkar 1,056 Posting Virtuoso

Try not to use the goto , have you considered using break instead

for(int i=0; i<10; i++) {
 if (i > 0)
  break;    // <- breaks out of the for loop ...
else
  cout << i;
}
OmniX commented: Thanks for the help +1
mitrmkar 1,056 Posting Virtuoso

Couldnt compile code:

ERROR:
Vector3.cpp||In function `int main()':|
Vector3.cpp|9|error: brace-enclosed initializer used to initialize `std::string'|
Vector3.cpp|9|error: brace-enclosed initializer used to initialize `std::string'|
Vector3.cpp|9|error: brace-enclosed initializer used to initialize `std::string'|
||=== Build finished: 3 errors, 0 warnings ===|

Oops, my bad, use ...

std::string inputs[3]  = {"1,2,3", "4,5,6", "7,8,9"};
mitrmkar 1,056 Posting Virtuoso

Why is the stringstream initialized within the forloop instead of outside?

That way you automatically get a 'fresh' stringstream object meaning that you don't have to take care of resetting it in any way.

mitrmkar 1,056 Posting Virtuoso

If I try using that while loop more than once, its useless as it is bypassed and keeps using the old values stored in the variables and dosent take in the seperate the new values.

Hmm .. I'm not quite sure what the actual problem is, but maybe the following helps to understand things (It's a modified version of what niek_e already posted)

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

int main()
{
    // 3 strings as input
    string inputs[3]  = {{"1,2,3"}, {"4,5,6"}, {"7,8,9"}};
    string buffer;
    int integer;

    // iterate through the 3 input strings ...
    for(int ii = 0; ii < 3; ++ii)
    {
        stringstream ss;
        // store the input string in the stringstream
        ss << inputs[ii];

        // extract and cout the numbers one at the time ...
        while (getline(ss,buffer,','))
        {
            // convert to an int
            istringstream strin(buffer);
            strin >> integer;

            cout << integer;
        }
    }

    cin.get();
    return 0;
}

Output is ...

123456789
mitrmkar 1,056 Posting Virtuoso

#include <winresrc.h> in the .rc file, that way the definitions of e.g. DS_MODALFRAME and WS_POPUP will be known. In addition to that, add #define IDC_STATIC -1 in the resource.h file.

mitrmkar 1,056 Posting Virtuoso

'This is a test'. When you save it and then open it in notepad, this is what it looks like:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}
\viewkind4\uc1\pard\fs20 this is a test\par
}

see? a whole lot of crap is added to the text file. How can I fix this?

The content is in Rich Text Format (RTF). Notepad does not understand it and hence displays it raw. Open the file with e.g. MS Word, and you'll see what you expected.

mitrmkar 1,056 Posting Virtuoso

First of all, please use code tags when you post your code.

You have an extra curly brace there ...

// }  <- extra curly brace here
~Quadrilateral() // Call Destructor
{
    cout << "\n\nThe Base Class Rectangle has been destroyed!" << endl;
};

[EDIT]
Oh well, niek_e got there first ...

mitrmkar 1,056 Posting Virtuoso

just shows last student records ten time instead of each student .

Isn't that quite obvious if you take a close look at the loop,

for(k=1;k<=10;k++)
{
    // do this ten times ...

    // ask the user for the file name <-> shouldn't you 
    // open the file before this loop?
    scanf("%s",filename);*/

    // open the file, start reading from the very beginning
    fp=fopen("filename","r");
    
    // grab the information ...
    fscanf(fp,"NAME= %s\tCOURSE ENTITLLED= %s\t ID NUMBER= %d\t DATE OF BIRTH= %s\tAVERAGE= %f\n",name,course_enrolled,&id_number,date_of_birth,average);

    // and display it ...
    fprintf(stdout,"NAME= %s\tCOURSE ENTITLLED= %s\t ID NUMBER= %d\t DATE OF BIRTH= %s\tAVERAGE= %f\n",name,course_enrolled,id_number,date_of_birth,average);

    // now close the file <-> shouldn't you close the file after this loop?
    fclose(fp);
}
mitrmkar 1,056 Posting Virtuoso

Print Dialog is not shown

That is because you specify the PD_RETURNDEFAULT flag, for details see

http://msdn.microsoft.com/en-us/library/ms646843(VS.85).aspx

mitrmkar 1,056 Posting Virtuoso

I think the library you need is libcomdlg32.a.

Generally, when you get linker errors related to Windows API functions, lookup the function's documentation in MSDN, scroll down to the bottom of page where you can find the name of the required .lib (i.e. in this case: Import library Comdlg32.lib). That gives you enough information to map the Win .lib file to the Dev-Cpp's counterpart.

mitrmkar 1,056 Posting Virtuoso

Futhermore, you have the variables the wrong way around, i.e. instead of a >> strin; use strin >>a;

Nick Evan commented: Duh... Missed that completely +8
OmniX commented: Thanks for the help +1
mitrmkar 1,056 Posting Virtuoso

You might use stringstream ...

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

int main()
{
    int a = 1;
    int b = 2;
    int c = 3;
    int d = 4;
    int e = 5;
    int f = 6;

    vector<string> abcd;
    stringstream sstrm;

    sstrm    << a << " " 
             << b << " " 
             << c << " " 
             << d << " " 
             << e << " " 
             << f;

    abcd.push_back(sstrm.str());

    return 0;
}

Note that vector has no append() member function, see vector reference

mitrmkar 1,056 Posting Virtuoso

i did. thats all i am using to find the mouse position. Is it completely right? :O

You might change it to

int xPos = GET_X_LPARAM(lParam); 
int yPos = GET_Y_LPARAM(lParam);

although that probably won't fix anything. Anyway, I meant that you might perhaps post the complete code you have for drawing the line.

mitrmkar 1,056 Posting Virtuoso

I am using DEV C++. Do I still need to link to libwinspool.a.

Yes, to link with libwinspool.a, open the Project/Options/Parameters tab, click Add Library or Object and browse for that library.

mitrmkar 1,056 Posting Virtuoso

But I am getting linker error.
" [Linker error] undefined reference to `OpenPrinterA@12' "

You (may) need to #include <winspool.h> If you are not using a MS compiler, you need to link with libwinspool.a, otherwise winspool.lib.

mitrmkar 1,056 Posting Virtuoso

sorry that doesn't work. I am trying to draw a line from where my mouse is when i click to where it is when i let go, if that helps. if i do it at 0,0 its fine but as i go further across and down the line isn't where my mouse is any more, it gets further and further away :(

You might post the code.

mitrmkar 1,056 Posting Virtuoso

Apparently, calling TTF_Quit before TTF_CloseFont will cause the error. Is there any easy way around this?

You might also consider using atexit()

mitrmkar 1,056 Posting Virtuoso

Obviously you don't have a class named CMyView , so you cannot use the provided example as is. Instead you could e.g. make the provided example a stand-alone function and use it as such, i.e. simply

BOOL GetPageSize(CSize &nRetVal)
{
    // rest of the example code here ...
}
mitrmkar 1,056 Posting Virtuoso

error C2511: 'Contributor::Contributor(std::string,double,Contributor::gender,int)' : overloaded member function not found in 'Contributor'
see declaration of 'Contributor'

In the class declaration, you probably meant to have a member variable like gender Sex; instead of enum gender;

mitrmkar 1,056 Posting Virtuoso

The function is malloc() , not maloc().

mitrmkar 1,056 Posting Virtuoso

You might want to set the HideSelection property of the RichTextBox to false.

mitrmkar 1,056 Posting Virtuoso

You might try something like the following, it removes all spaces that precede an '>'.

const std::string srch = " >";
std::string::size_type pos;

while(std::string::npos != (pos = Line123.find(srch)))
{
    Line123.erase(pos, 1);
}
mitrmkar 1,056 Posting Virtuoso

I dont know why this is happening and what could be done about that.

form2->TopMost::set(true);

It is happening because that is what the above line does.
Maybe you could instead try to use the Form2's Owner property, i.e.

Form2 ^form2 = gcnew Form2;
// Form1 owns the form2 ...
form2->Owner::set(this);
form2->Show();

That way Form2 stays above Form1, but won't get in the way of any other windows.

mitrmkar 1,056 Posting Virtuoso

^^^
EDIT: became obsolete

mitrmkar 1,056 Posting Virtuoso

The prototype and the definition mismatch ..

int ConvertANSI(char sChar [] );
int ConvertANSI(char szText [] )
{
	return static_cast<int>(szText[0]);
}
mitrmkar 1,056 Posting Virtuoso

why wont this one work???????....

Be more specific about what is not working, spend some time trying to describe the exact problem(s), instead of just posting slightly modified code time after time (without code tags).

Then about arrays and indexes, assuming that you eventually choose to have an array of 5 integers, as suggested by niek_e, i.e.

int candidate[5] = {0,0,0,0,0};

Now to iterate through all the 5 indexes using a for loop, goes from 0 to 4

for (int i = 0; i < 5; i++)
{
     cout << "candidate[" << i << "] is: " << candidate[i] << '\n';
}
mitrmkar 1,056 Posting Virtuoso

Perhaps SEPARATOR?

mitrmkar 1,056 Posting Virtuoso

It is #define CLIP_MOUSEOUT 0 instead of #define CLIP_MOUSEOUT = 0

mitrmkar 1,056 Posting Virtuoso

You have to check against std::string::npos the return value of the find() method.

std::string::size_type pos = string1.find("*");

if(std::string::npos != pos)
{
    // found a match at 'pos'
}
else
{
    // not found
}

For information on std::string::npos see
http://www.cplusplus.com/reference/string/string/npos.html

mitrmkar 1,056 Posting Virtuoso

You only have storage for two CTreeComponent pointers ... CTreeComponent* m_children[2]; the add(...) method could check that you are not using out of bounds indices.

mitrmkar 1,056 Posting Virtuoso
#define NUMBER 0
clips[ NUMBER ].x = 240

Would you mind posting the error message(s) that you get using the above non-working construct? And what is your compiler?

mitrmkar 1,056 Posting Virtuoso

It has to be ...

fstream file_op2(filename.[B]c_str()[/B], ios::out);
mitrmkar 1,056 Posting Virtuoso

i wan to write into different files......i am using a loop so i wan the name to be generated automatically...and not as in the coding.....if its like in the coding then the classes will be written in 1 file....i wan to be like, when the first class is found i want it to write into a new file maybe test.1 so it continues till the last class is detected..but i wan it in the loop format....i wan the path of the file to be generated automatically with different names so each class will be written inside different files..

Then put the filename together like

[B]int[/B] counter = 1;
stringstream sstrm;
sstrm << "c:\\file#" << counter << ".txt";
string filename = sstrm.str();
cout << filename;
mitrmkar 1,056 Posting Virtuoso

Not sure what the actual problem is, but maybe you are missing ios::ate so that the file does not get truncated each time you open it, i.e.

file_op2("c:\\arun.txt", ios::out|[B]ios::ate[/B]);
mitrmkar 1,056 Posting Virtuoso

I've changed the whole functions in LinkList class and Node Class to take this kind of parameter (const string &x)

and I ended up with two error messages from the compiler *they're the same*
: error C2678: binary '=' : no operator defined which takes a left-hand operand of type 'const class std::basic_string<char,struct std::char_traits<char>,cla

!!! what should I do?

For example the remove() function cannot be passed in a [B]const [/B]string & , because the function modifies the argument. So you need to have ... bool remove ( std::string & x );

Q8iEnG commented: Perfect member :) +1
mitrmkar 1,056 Posting Virtuoso

for (const string &x)
should I change the type of the parameters of the whole functions under LinkList to take (const string &x)?

Use [B]const [/B]string & with any function that will not modify the argument it receives, e.g. the Node class's constructor and the insert() function.

Why we did pass it as a reference?

To avoid temporary string objects from being generated.

because I don't want the original data in the file to be changed!

Assuming you have the following constructor Node ( [B]const [/B]std::string [B]&[/B] x ); The following insert() works without changing x

bool insert ( [B]const[/B] std::string & x )
{
    // x comes in as const and hence its value
    // cannot be changed in this function

    if ( !(tmp= new Node(x) ) )
        return false;

    count++;

    if ( !head )
    {
        head = last = tmp;
        return true;

    }

    last -> link = tmp;
    last = tmp;
    tmp = NULL;
    return true;

} // end function insert
mitrmkar 1,056 Posting Virtuoso

do you advice me to use what you said insert( const char * lib ) ???

Not anymore. You might change the type of the data member from char to std::string .
And make the necessary (similar) changes throughout the LinkList and Node classes.

The insert() function, for example, would change to LinkList::insert( const std::string & x ); And you would use it ...

while( getline( fin, lib, '\n' ) )
{
    game.insert( lib );
    cout << lib;
}

And the Node class would look like ...

// Begin Class Node
class Node
{
public:
    std::string data;
    Node *link;

    Node ( const std::string & x )
    {
        data = x;
        link = NULL;

    } // end constructor for class Node

}; // end class Node