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

What is the question??

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

The reason is usually performance, but that's not as common as some would have you believe.

At least not any more with present-day fast computers. When I started out in the 1980s computers were ungodly slow, so we had to get every bit of speed that we could muster. Many of the things we did back then I wouldn't bother with today.

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

Check if any of the windows are derived from CDocablePane.

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

White space includes space, line feed, and tab characters. So testing for just space isn't right. And line 5 uses the assignment operator = instead of the boolean operator ==.

The easiest way to test for white space is to use the standard macro isspace()

char char1;

// iterating through a file

if ( issapce(char1) )
{
cout << "WHITE SPACE" << endl;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's because you're using eof() incorrectly eof() doesn't know it's end-of-file until an attempt is made to read it. A better loop is like this. Note: eof() is unnecessary, at least I've never found a use for it.

while(in_file>>eve>>am>>dat>>bal )   
    {
        cout<<eve<<setw(10)<<am<<setw(20)<<dat<<setw(10)<<bal<<endl; 
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In the few posts which I have had on here asking for help I have generally had to solve the problem myself (and that is always the best way right?)

Actually -- yes, that is right. We are here to "help" you solve the problem, not solve it for you. You learn a great deal more if you are forced to research the problem and write the code yourself. Programming is all about problem solving, not about getting someone else to do your work for you. How long do you think you will last on a job if you can't solve programming problems?

Additionally, almost everyone here are unpaid, they post here and try to help you out with only the goodness of their own hearts. So don't get mad when volunteers ask you to post the code you try so that they can help you. Instead, you should be greatful for whatever help you get. If you want paid tutors then it's going to cost you a lot more than you have to pay to ask questions on DaniWeb (which is free).

And don't get too upset if someone disagrees with you. Heaven only knows the number of times I've been critisized for things :) I'm not right about everything, and all the regulars here knows it. My post cound only means I'm a blabbermouth, has no relationship to being an expert at anything.

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

if someone could help with at least part of it

You mean you want us the translate the entire program? What exactly do you mean by "last part"?

andreagonz9 commented: Hi, sorry for the confusion. I am having problems with all of the code, I'm teaching myself how to use assembly language by reading the theory from a book; and have not been very succesful. translating everything would be to much to ask, do I just need at +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You need to put pragmas around unmanaged code. The only way to find out if it will fix your problem is for you to test it on the computer that does not have visual studio.

[edit]I don't have VS 2010, but VS 2013 compiles and works ok without the pragmas on the computer that has vs installed, just as you reported. I don't have a computer without VS so I can't test that part of your problem.

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

but can i do these?

Not if you are using the VARIANT from windows.h. If you aren't doing any COM stuff (which you probably are not), then use the types described by Mike, above.

cambalinho commented: thanks +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Below is a simple example. Here is a complete list of vt types. Of course if you create your own class then you can do whatever you want by making up your own type code macros.

#include <windows.h>

void foo(VARIANT* vt)
{
   switch(vt->vt)
   {
        case VT_EMPTY:
        case   VT_NULL:
            break; // nothing to do
        case   VT_I2:
            cout << "Short Integer: " << vt->ival << '\n';
            break;
        case   VT_I4:
            cout << "Long Integer: " << vt->llval << '\n';
            break;
        case   VT_R4: 
            cout << "float: " << vt->fltval << '\n';
            break;
        case   VT_R8:
            cout << "double: " << vt->dblval << '\n';
            break;
   }
 }


 int main()
 {
    VARIANT vt;
    VariantInit(&vt); // initialize the VARIANT
    vt.vt = VT_I4;
    vt.llval = 123;
    foo(&vf);
}
cambalinho commented: thanks +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

windows.h already contains a variant structure (link here). All it is is an union of a lot of objects, and an integer to indicate the type of object that is used.

Here is a simplified version of it, the data members in windows.h do not have the same names as in my code below, but it's the same idea.

struct variant
{
   int vt;
   union
   {
       char*ptr; 
       short sdata;
       unsigned short usdata;
       int idata;
       unsigned int uidata;
       long ldata;
       unsigned long uldata;
       void* unknownptr;
    };
};
cambalinho commented: thanks +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Text files can not be changed directly. Read the file into memory, make changes in memory, then rewrite back to the file.

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

I had to google for it because I never heard of it. But my emoticon is (:| (Yawn)

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

What does the acrnym IBM stand for? A: It's Better Manually.

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

Fruit Cake.

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

New buttons are nice -- but will you please add tool tips so that we know what they are? For example buttons for Report Post (Flag) and the other one next to it (I have no idea what it does).

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

Do it in small parts so that you don't get overwhelmed. First, write the program and inputs three integers. After you get that working, you can add some more to sum up the three integers as you enter them. After that, so each of the other parts, and soon you will have the program written.

JeffGrigg commented: Excellent advice for a beginner. +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Most desserts are bad for us, but we can't live forever so might as well enjoy it :)

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

Did you buy it yourself or get it as a gift? When you have to pay for it yourself then you'll be a little more careful.

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

you can also do it without a loop by calling memcmp(), which compares two arrays byte-by-byte.

int a[] = {1,2,3,4,5};
int b[] = {1,2,3,4,5};

if( memcmp(a,b,sizeof(a)) == 0)
{
   printf("They are the same\n");
}
else
{
   printf("They are different\n");
}
Assembly Guy commented: Ahh the simple solution. Awesome +5
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you write a prototype for Complement() before main() or does the function appear in the source file before main() ? For example:

void compliment(int a[], int m); // Function prototype

int main()
{


}

void compliment(int a[], int m)
{


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

Did you compile for debug then use it's debugger to single-step thorugh the program? How many elements are in the data array? Does the value of (j+i) exceed the number of elements in the array?

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

Functions are coded as normal.

class MyClass
{
public:
   static int x;
   static int foo();
 };

int MyClass::x = 0; // static variables must also be declared like globals
int MyClass::fo()
{
    return x;
}

int main()
{
    MyClass::x = 1;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

i understand that i can't use a varname outside the functions\class's with '::' operator

Make the variable static and you can use it outside the class with :: opertor.

class MyClass
{
public:
   static int x;
 };

int MyClass::x = 0; // static variables must also be declared like globals

int main()
{
    MyClass::x = 1;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I see the return statement on line 16, but nowhere else. What happens if the test on line 10 fails -- what will the function return??

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

It's almost a waste of time learning win32 api because it has been supersedded by .NET Framework. Your time would be more well spent by learning Windows Forms using CLR/C++, C# and VB.NET languages, all which use .NET Framework functions. It wouldn't surprise me if win32 api was someday (in the next 10 years) obsolete and no longer supported.

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

For detailed explanation of each argument you need to read this article. There are two functions -- CreateWindow() and CreateWindowEx(). If you compare the arguments of the two functions the only difference is the first argument, which are additional window styles not used in the first function.

cambalinho commented: thanks +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Have you tried to google for borderless windows? I found several possible solutions, here's a youtube video (don't know if it's what you want or not)

cambalinho commented: thanks for all +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

setprecision() is in effect until you call the funcion to change the value for floats and doubles. Assuming rate is either float or double, on line 3 call setprecision(0) to not display any decimals. Then on line 4 you have to call setprecision(2) again.

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

Here is a good tutorial that explains exactly what you are looking for.

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

Here's why macros are evil critters.

cambalinho commented: thanks +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's nice to see all you people love your mothers so much.

<M/> commented: ROFL +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why would anyone abuse SNAP

To buy booze, street drugs, and other things that are not covered under SNAP.

How would you being a WalMart cashier beable to tell if the people were abusing it or not

Because there is a list of items that people can get. If it's not on the list, then it can't be bought with SNAP (or WIC).

Even if this imaginary abuse is going o

Nothing "imaginary" about it.

Why is that a bad thing?

It's not a bad thing -- the bad thing is the abuse of the system, not that people can get free food.

And its not like SNAP is can be spend on drugs or jewlery or other unnecessary luxuries.

In theory, yes. In practice, maybe or maybe not.

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

Can you explain to me how Republicans

Nope, I'm not Republican, although I have voted Republican presidents just as I have voted for Democratic presidents.

defund SNAP

Yes, because it doesn't work due to too many people abusing the system, I've seen it with my own eyes when I was a recent WalMart cashier for 5 years.

keep millions of Americans from receiving affordable, basic health care

What makes you think they already receive health care? Just walk into any emergency room in USA and you will see people who have no health care insurance.

loosen gun laws so that even more people die

No one wants to do that. Republicans are agains gun control, not deregulation. I favor some regulation such as banning assult weapons not because such regulations will magically remove them from the hands of criminals but because it gives law enforcement ammunition to arrest people who have them.

AD - you are obviously opposed to the ACA.

I'm not opposed to the idea of ACA, from what I've heard it is just a bad law. One father said of TV just this morning that it will cost him at least another $500.00 per month. Insurance companies have cancelled the policies of several million Americans, leaving them with no insurance at all. I don't know how anyone can say that is an improvement.

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

You need to put a loop around the entire program, such as from line 20 to about line 373 (just before the return statement).

It's hard to believe you are not allowed to use functions! No programmer in his/her right mind would write that big of program without using functions to make it more readable.

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

You should use SetWindowLongPtr() so that it will be compatible with both 32 and 64 bit version of MS-Windows.

cambalinho commented: thanks +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The blue background works correctly in the code you posted here.

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

The shift is not necessary, should be able to just or the forground and background colors together as you have done without the shift. As for your question, did you try it to see if it works?

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

Sounds like something a 12-year-old might post.

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

You'd have to redeclare the function even if you could overload ::, so what's the problem?

class test
{
   public:
       virtual void Created() {cout << "Hello from test class\n";}
       test()
       {
           Created();
       }
};

class Child : public text
{
public:

   virtual void Created() {cout << "Hello from Child\n";}
 };

 int main()
 {
     Child c;
     c.Created();  // call Created in Child class
     c.test::Created(); // call Created in test class
 }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The way to check it is to run it and see if it does what it's supposed to do. If it doesn't then the program is wrong. From the code you posted I believe you have just scratched the surface of what the assignment requires.

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

lines 11 and 12: text is an array of char, not an array of structures, it should be consoletext.

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

The function is used to write a 2 dimensional array of bytes to the screen, so the second parameter is a 2d array of structures.

Example program is given here. This example reads the text that's on the screen then changes the coordinates so that the text will be written in a different position on the screen. If you want to write all new text you don't have to read from the screen but instead create a new array of structures and fill them in with the text/attribute info

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

Yes, you could do that, but that function is used to change the color of existing text. If you want to write new text in a specific color then call SetTextColor()

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

Yes

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

You need to read the remarks for that function:

If the number of attributes to be written to extends beyond the end of the specified row in the console screen buffer, attributes are written to the next row. If the number of attributes to be written to extends beyond the end of the console screen buffer, the attributes are written up to the end of the console screen buffer.

The last parameter to that function is a pointer to a DWORD object that is created in your program.

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

Leap year occurs every 4 years. If the year is evenly divisible by 100 then it is not a leap year, unless it is evenly divisible by 400. For example: the year 2000 was a leap year because it is evenly divisible by 400, but the year 1800 was not a leap year because it is evenly divisible by 100 but not 400. So 1600, 2000 and 2400 are leap years but 1700, 1800, 1900, 2100, 2200 and 2300 are not.

Now, in the function you posted, the && and || operators have the same precedence, so just read from left to right.

rubberman commented: Good explanation AD. :-) +12
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

CreateFont() or CreateFontIndirect(). You are already calling that in the code you postged in your other thread.

Also -- you shouldn't have two threads for the same question, it just causes confusion. This is my last post in this thread.

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

because letters are wider than spaces. Use a fixed-width font and it should work.

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

Doesn't blink, using VC++ 2012. This version blinks. I marked the lines I changed with //<<<<<<<<<<<<<<

//blinktext.h
#include <process.h>
#include <string>
#include <memory.h>
#include <windows.h>
#include <iostream>

using namespace std;

struct Blink
{
    string Text;
    int x;
    int y;
    int TextColor;
    int BackColor;
};

unsigned __stdcall BlinkLoop(void *params)
{
    Blink *p = static_cast<Blink *>(params);

    size_t tlen = p->Text.length()+1; //<<<<<<<<<<<<<<
    char *EmptyText = new char[tlen];
    memset(EmptyText, 'd', tlen);

    HDC hDC=GetDC(GetConsoleWindow());

    while (true)
    {

        SetBkMode(hDC,TRANSPARENT);
        SetTextColor(hDC,RGB(0,255,0));
        TextOut(hDC,p->x,p->y,p->Text.c_str(),(int)p->Text.length());//<<<<<<<<<<<<<<
        Sleep(500);
        SetTextColor(hDC,RGB(0,0,0));
        SetBkMode(hDC,OPAQUE);
        SetBkColor(hDC,RGB(0,0,0));
        TextOut(hDC,p->x,p->y,EmptyText,(int)p->Text.length());//<<<<<<<<<<<<<<
        Sleep(500);
    }
    return 0;
}

void TextBlink(string text, int x, int y, int TextColor, int BackColor)
{
    Blink *b=new Blink;
    b->Text=text;
    b->BackColor=BackColor;
    b->TextColor=TextColor;
    b->x=x;
    b->y =y;
    _beginthreadex(NULL, 0, BlinkLoop  ,b, 0, NULL);
}



int main()
{
    TextBlink("Hello world", 20,20,3,3);
    cout << "hello world";//like you see, the caret(text cursor) isn't losed


    cin.get();
    return 0;
}
kal_crazy commented: Yup this works as well +2