Hey I want a code for a please wait with dots in front of it (writes some and delete them and starts again) or a / or \ that rounds.
thanks

Oh you want something like a gui Progress Control, but just for text mode program. You would probably want to put the code for that in another thread while the main program (thread) is doing other things.

Of course, no way to do that in platform-independent manner. Probably the simplest progress bar surrogate for console applications is conio.h based class with feedback call from the (silent) main loop.
Try this improvisation:

/// Progress indicator console surrogate.
/// Place in conticker.h (no dependencies)
class ConTicker
{
public:
    ConTicker() {}
    static void start();
    static void tick();
    static void stop();
private:
    static time_t  t;
    static size_t  i;
    static const char* c;
};

// ConTicker implementation (conticker.cpp)
// Dependencies: <conio.h>, <ctime>, "conticker.h"
time_t ConTicker::t = 0;
size_t ConTicker::i = 0;
const char* ConTicker::c = "-\\|/";

void ConTicker::start()
{
    _cputs("\r\nWorking: -");
    time(&ConTicker::t);
    i = 0;
}

void ConTicker::tick()
{
    if (ConTicker::t) {
        time_t t;
        time(&t);
        if (0.2 < difftime(t,ConTicker::t)) {
            ConTicker::t = t;
            _cputs("\rWorking: ");
            ConTicker::i = ((ConTicker::i+1)&3);
            _putch(c[ConTicker::i]);
        }
    }
}

void ConTicker::stop()
{
    ConTicker::i = 0;
    ConTicker::t = 0;
    _cputs("\rDone!     \r\n");
}
// End of conticker.cpp

// Test (dependencies: <windows.h>, <iostream>, "conticker.h")
using std::cout;
using std::endl;

int main()
{
    cout << "Let\'s go..." << endl;
    ConTicker::start();
    for (size_t i = 0; i < 200; ++i) {
        Sleep(100); // Do what you want...
        ConTicker::tick(); // Post ticker
    }
    ConTicker::stop();
    return 0;
}

Don't call ConTicker::tick() on every loop, select appropriate M divider for

ConTicker::start();
... main program loop
 if (main_loop_counter++ % M == 0)
    ConTicker::tick();
...
ConTicker::stop();

PS. Don't print anything in the main loop ;)

Hey there are some problems.
1-if i place the definition of your class's functions and variables in another file,The compiler you know can't...ahhh...find them.No i tried as you said and it came up with an error like:

undefined reference to `ConTicker::start()'

and two more for your two other functions so i included conticker.cpp,too but it came up with:

error: redefinition of `class ConTicker'

error: previous definition of `class ConTicker'

in the line 4(in your post's code tag).

and one more thing...
Could you explain a little about the whole algorithm.you know if i wanna learn c++ i must know these things too and tell what are those lines in your second code tag.
thanks

Sorry, but I can't comment every line in my snippet: it's too expensive. This is a plain C++. Read about time and difftime C library functions. Imagine that it's your homework ;)

No special magic in the code files: place the class definition in .h file, place its implementation in .cpp file (don't forget #include .h file there), #include .h file in every module where ConTicker used - that's all.

If you can't do that, better don't waste a time to such trinkets as rounded sticks on your console, learn basics of programming ;)...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.