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

To avoid using non-stnadard functions in conio.h, you can use win32 api console functions. Here is how to filter the keys you don't want. This is not the entire program you need, but will get you going so that you can do your own thing with it.

#include <windows.h>
#include <iostream>
#include <vector>

int getkey()
{
    bool rvalue = false;
    const int MaxEvents = 16;
    HANDLE hStdin =  GetStdHandle(STD_INPUT_HANDLE);
    DWORD dwNumRead = 0;
    DWORD dwNumEvents = 0;
    INPUT_RECORD buf[MaxEvents];
    if( GetNumberOfConsoleInputEvents(hStdin, &dwNumEvents) )
    {
            if( dwNumEvents > 0)
            {
                memset(buf, 0, sizeof(buf));
                // Get the number of events available at the console
                if( ReadConsoleInput(hStdin,buf,MaxEvents, &dwNumRead) )
                {
                    // process each event
                    for(DWORD i = 0; i < dwNumRead; i++)
                    {
                        // if keyboard event
                        if( buf[i].EventType == KEY_EVENT)
                        {
                            KEY_EVENT_RECORD* pKey = (KEY_EVENT_RECORD*)&buf[i].Event.KeyEvent;
                            // if key down event
                            if( pKey->bKeyDown == TRUE)
                            {
                                // test the key type.
                                if( isdigit(pKey->uChar.AsciiChar) )
                                {
                                    return pKey->uChar.AsciiChar;
                                }
                                else if( pKey->wVirtualKeyCode == VK_RETURN)
                                    return VK_RETURN;
                            }
                        }
                    }
                }
            }
    }
    return 0;
}

int main()
{
    int key = 0;
    while( key != VK_RETURN)
    {
        while( (key = getkey()) == 0)
            Sleep(100);
        if( key != VK_RETURN)
            std::cout << (char)key << ' ';
    }
    std::cout << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It seems like some people are not out of the woods yet -- here are some critical dates (from twitter)

# 2010-01-01 Fri - Y2.01K. There will be some who have coded only for Years 200#
# 2010-01-01 Fri - Sorting YYMMDD decade-reversed covers 1990-2009 only
# 2010-01-01 Fri - Reported ANSI C library overflow. Very dubious. RSVP if you can explain it

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

how can I not confuze myself .. what is the best way to understanding pointers

and the ways to manipulating them as in the first post ?

Here is a tutorial by DaWei over on ProgrammingForum.org.

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

Welcome to DaniWeb -- don't be so afraid of showing your age :) We are all another year older now.

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

After 33 posts you should know where to post this! But Happy New Year anyway :)

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

Put your finger on the Shift key, scroll down with the mouse to highlight all the items you want, then press the Delete key. Or you could just delete them all then rebuild the inventory page.

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

Pass it as in the second example: void func2(tc_struct** ptr2) Its not necessary to add more stars and pointers to pointers to pointers ...

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

In order to make it work I had to change the Source to "Feeder" (see attached)

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

The calendar is an arbitrary imposition of order onto civilizations blundering around the sun.

In general, rather than AD and BC - the years are numbered Common Era/Before Common Era (it is currently 2009 CE soon to be 2010). There are many cultures that do not accept the birth of Christ as a valid starting point but realize the we need a common calendar hence Common Era.

(Jews, Hindus, historian etc come to mind).

It's a know fact that Jesus was not born on 1 BC. Most likely he was born some 4-6 years before that. It's also a known fact that he was not born on December 25th. That date was just chosen by the Pope to celebrate His birth, most likely because it coincided with existing fall/winter celebrations.

To paraphrase William Shakespeare -- BC by any other name is still BC.

Interesting is how Chinese number the years

Although the Chinese calendar traditionally does not use continuously numbered years, outside China its years are often numbered from the reign of Huangdi. But at least three different years numbered 1 are now used by various scholars, making the year 2009 "Chinese Year" 4707, 4706, or 4646.[2]

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

Only 14 hours and 30+ minutes to go! Happy New Year everyone :)

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

I agree -- the replies are a little difficult to follow and read due to the way they are formatted. Just use normal forum formatting would probably be better.

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

Instead of just begging for code, this link is an example of how you should have made the request. Notice that he did not ask for code but asked specific questions about what he didn't understand.

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

This is a simnple grade-school level math problem.

amount = 25
distance -= 300
if distance is greater than 0 then amount = amount + 15 * ((distance % 200)+1)

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

The program you are trying to create is probably already running on your computer. The compiler can not overwrite the *.exe file if it is already in use on your system.

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

Move line 61 up outside that loop. srand() should only be called once during the lifetime of the program.

Delete line 64. see above comment.

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

Do you thik that Qt is better?

Not if you don't know the first thing about C/C++. Learn the language first.

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

Did you try google?

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

Same answer as in this thread that was posted within the past 9 hours.

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

int main()
{
   HWND hWnd = GetConsoleWindow();
   ShowWindow(hWnd,SW_HIDE);
}
Excizted commented: Useful! +1
pspwxp fan commented: do u have such an easy solution 2 everything? +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Was that exactly how the problem was given to you? As posted the requirements are ambiguous. What exactly does it mean by "six variables ...
"? Are they strings, integers, structures, or something else? And the return value -- is it supposed to be in milliseconds, seconds, minutes, hours, days, months, years, decades, centuries, etc. ? And what if the two times span two or more days?

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

You can cal ShellExecute()

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

Windows 7 crushed Vista in early launch sales
By Matthew DeCarlo, TechSpot.com
Published: November 5, 2009, 1:22 PM EST

By now, nearly everyone can agree that Windows 7 is at the very least a marginal improvement over Windows Vista, so its success comes as no surprise. According to research by NPD Group, Microsoft sold 234% more boxed versions of Windows 7 than it did Vista during the first couple days of sales. The research firm's data covers sales from October 18 to 24 and includes Windows 7 presales.

Windows 7 has also pulled in more cash thus far, with 82% greater revenue than Vista. NPD notes that a combination of early discounts on presales and a lack of promotional activity for Windows 7 Ultimate caused the lopsided revenue. Windows 7 Home Premium Upgrade was the top selling SKU, with an average selling price of $76. Windows 7 Pro Upgrade followed in sales, with an average price of $147, and the $149 Windows 7 Home Premium Family Pack came in third place.

Microsoft's new operating system experienced a 40% boost in market share, and has noticeably increased PC hardware sales.

http://www.techspot.com/news/36841-windows-7-crushed-vista-in-early-launch-sales.html

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

I normally hate electric guitars, but ... this one is just foot stomping great! :) :)

Scroll down the page and listen to Cannon in D on electric guita -- also good.

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

line 29 is wrong. eof() doesn't work that way.

file.seekp(0, ios::begin); // start at beginning of file
while( File.read((char*)&User, sizeof(person)))
{
     // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

yep thats the one .

Well since i have decided to jump into this , i would be more adventurous and not confine myself to windows , so is there ne book on linux ,which can teach this thing in depth ?

If you want to write os-independent code then use the Boost library classes and functions.

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

Hi,

Firstly, wait! Do not EVER use CreateThread(). I say it because it's an API call and will be available for execution, even for a program which uses the single threaded version of the CRT! The results may not be pleasing. By calling the compiler provided function to create a thread, you will never be able to commit such a blunder, because the compiler will catch you (the thread creation call won't be available for use while linking to the single threaded version of the CRT).

Of course anything can be dangerous if you just blindly toss api function calls at your program with no thought. CreateThread() works great in multithreaded environments. I have used it many many times over the past 10 years in MFC programs with Visual Studio compilers. There has never ever been a problem with it.

Also, initializing the CRT won't happen with CreateThread(). The MSDN documentation for CreateThread() neglects to mention this extremely important trait.

I'm not sure that is even relevant to the issue. Why would I want to initialize the CRT just to do some number crunching in another thread? The CRT has already been initialized on program startup by the main thread.

If you're using the Visual C++ compiler, you should use _beginthread or _beginthreadex (recommended) or if you're using MFC, you MUST use AfxBeginThread.

It depends -- CreateThread() works ok in MFC if the new thread will not be interacting with MFC objects, such as the new thread can not …

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

Although that would rarly exist, here is how to avoid such directories. This also will not parse hidden directories, such as the recycle bin.

__int64 TransverseDirectory(string path)
{
    WIN32_FIND_DATA data;
    __int64 size = 0;
    string fname = path + "\\*.*";
    HANDLE h = FindFirstFile(fname.c_str(),&data);
    if(h != INVALID_HANDLE_VALUE)
    {
        cout << path << '\n';
        do {
            if( (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
            {
                if( !(data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) 
                    && !(data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
                {
                    // make sure we skip "." and "..".  Have to use strcmp here because
                    // some file names can start with a dot, so just testing for the 
                    // first dot is not suffient.
                    if( strcmp(data.cFileName,".") != 0 &&strcmp(data.cFileName,"..") != 0)
                    {
                        // We found a sub-directory, so get the files in it too
                        fname = path + "\\" + data.cFileName;
                        // recurrsion here!
                        size += TransverseDirectory(fname);
                    }
                }

            }
            else
            {
                LARGE_INTEGER sz;
                // All we want here is the file size.  Since file sizes can be larger
                // than 2 gig, the size is reported as two DWORD objects.  Below we
                // combine them to make one 64-bit integer.
                sz.LowPart = data.nFileSizeLow;
                sz.HighPart = data.nFileSizeHigh;
                size += sz.QuadPart;

            }
        }while( FindNextFile(h,&data) != 0);
        FindClose(h);

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

>>This code is wrong.
There are as many ways to do something as there are programmers to do it. What exactly is wrong with the code I posted? Post a link to the article you site.

BTW there is no such thing as an "MSDN Official sample". They just provide samples, there is nothing "official" about them.

[edit] reparse points have nothing at all to do with the topic of this thread. So it becomes obvious you don't have the slightest clue what you are talking about.

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

Just use CreateThread() -- its simple to use because most of the parameters are 0 or NULL. I have not used the boost library, so I don't know how they work.

Creating threads is easy, making them work together may be more problematic. If two or more threads have to access a common object then you will have to implement thread synchronization via mutex or critical sections.

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

Are you using MFC? CMainFrame doesn't have a graphical interface, so the answer is NO.

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

<oops! already answered in another thread>

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

Dani, can you let us use smilies in our signatures? I wanted to put :) in my signature but it didn't work.

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

I see what you mean. I found a post by jbennet that had -7, upvoted it, and it went to 0.

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

That's good news for me? Thank you. But I still have 7 negative votes in the last entry on that thread. Maybe you looked at the wrong post? I really don't know why they are negative, other than probably someone just being an (donkey's butt).

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

Getting the number of files, or folder size, by either of the two previously posted methods goes pretty quickly (depending on file system speed of course). If what you have in mind doing takes a considerable amount of time then you will probably not see only very little pause while counting the files. Of course that will depend on how many folders you want to process, such as the entire C: drive.

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

Find out what book your class will require, buy it and study it. Other than that, there are lots of good books, see the Stick thread about c++ books.

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

What compiler did you use? I compiled it with vc++ 2008 Express and got a lot of warnings about using uninitialized variables. Pay close attention to your compiler's warnings because they are often actual errors.

[edit]I compiled it with Code::Blocks (with MinGW) and it does not produce the warnings about uninitialized variables. Even -Wall flag does not produce the warnings.

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

If you look back at Prashw on Sep 27th, 2006, he has 'CODE' written in the code. I have a feeling that I have to write code in those spaces, but i have no idead what to write there, sorry for my inexperience! and my late reply :)

You don't have to do anything there -- just delete the lines that contain CODE. He was attempting to use CODE tags, but didn't do it correctly. Also note that the code contains two files -- a *.h file and a *.cpp file. You can put all that into one *.cpp file if you wish -- just delete the file names and duplicate includes.\

Here, I fixed it up for you (except the formatting -- its terrible.)

#include <iostream>
#include <windows.h>
#include <string>
#include <conio.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
using namespace std;



#define FC_DTRDSR 0x01
#define FC_RTSCTS 0x02
#define FC_XONXOFF 0x04

#define ASCII_BEL 0x07
#define ASCII_BS 0x08
#define ASCII_LF 0x0A
#define ASCII_CR 0x0D
#define ASCII_XON 0x11
#define ASCII_XOFF 0x13


HANDLE SerialInit(char*, int); 

char SerialGetc(HANDLE*);

void SerialPutc(HANDLE*, char);





// Flow control flags

#define FC_DTRDSR 0x01
#define FC_RTSCTS 0x02
#define FC_XONXOFF 0x04

// ascii definitions

#define ASCII_BEL 0x07
#define ASCII_BS 0x08
#define ASCII_LF 0x0A
#define ASCII_CR 0x0D
#define ASCII_XON 0x11
#define ASCII_XOFF 0x13
using namespace std;
// variables used with the com port
BOOL bPortReady;
DCB dcb;
COMMTIMEOUTS CommTimeouts;
BOOL bWriteRC;
BOOL bReadRC;
DWORD iBytesWritten;
DWORD iBytesRead;

HANDLE SerialInit(char *ComPortName, int BaudRate) 
{
HANDLE hCom;

hCom = CreateFile(ComPortName, 
GENERIC_READ | …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

On second thought, that may not be so easy to change for new programmers. So here is a version that will return the size of all the files in the folder and its sub-folders.

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

This shows how to get the size of all the files in a folder, and all its sub-folders on MS-Windows operating system. It uses recursion to transverse all the directories, and return a 64-bit integer. It was compiled with VC++ 2008 Express and Code::Blocks Version 8.02 with MinGW compiler.

Excizted commented: Useful code snippet. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The same thing can be achieved by calling FindFirstFile() and FindNextFile(). Here is a function that will do everything except sum up the file sizes. And that feature could be easily added.

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

Please deposit $5,000.00 USD in my paypal account and I will be happy to do your homework for you.

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

If you have a 64-bit computer than you will want to download the 64-bit version of *nix. But be warned that 64-bit is not well supported, that is you might have problems getting some 64-bit device drivers and programs. I never had problems with the os itself, just device drivers and Abode Flash Player. Ubuntu works better on my 64-bit computer than Fedora 11, easier to install.

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

Worked for me. I don't know if the size is correct or not but I got 4096 for the directory size. All I did was change the path to one that's on my computer. I'm running Windows 7, VC++ 2008 Express if that matters.

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

When all else fails curse Bill Gates and buy a new scanner.
Lol

Why Gates? Its not his fault that HP has not upgraded their software yet. They have had at least a year to get it done.

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

Search these forums because the solution has been posted several times.

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

I am hoping for a robotic laser beam lawn mower. :)

Does that come with a teenager to push it ? :)

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

I got my Christmas, New Years, Birthday, Valentines (for the next 10 years or so) present about two weeks before Christmas -- a new HDTV with Bose sound system. A couple of guys brought it out to my house, set it all up, and took away all my old stuff.

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

I meant to say Form1^ ff = gnew Form1; Current version of CLR does not allow you to use * instead of ^. And you can not use gnew without the ^.