#include<conio.h>
#include<windows.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
#include <stdio.h>
void loading();
void gotoxy(int x, int y);
int color(int x);
void gotoxy(int x, int y);
int main(){
void loading(){
int c;
for( int x = 0; x <= 100; x++)
{
gotoxy(c,10); printf("%c",219);
gotoxy(40,12); color(10); printf("%d %%",c);
color(15);
c += 3;
Sleep(100);
}
}
system("pause>0");
int main(){
system("cls");
{
HANDLE hConsoleOutput;
COORD dwCursorPosition;
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
};
}
int color(int ncolor){
int i=ncolor; // the value of ncolor is the color code
HANDLE ConsoleSettings;
ConsoleSettings=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(ConsoleSettings,i);
}
please help to produce a loading bar with percent progress[code]
You can "draw" a loading bar by using symbols. Like:
|**** |
And you can use your gotoxy function to go back and draw progressively more * symbols.
But really... a loading bar doesn't make any sense at all unless you're actually loading something. And how you make a loading bar progress accurately depends on what you're loading. IE, it has to be a process you can interrupt periodically to get an update on its status.
You need to have a way to get notified at different points during the process. Just loading a single program would be difficult to have a loading bar for... because there isn't really any way to interrupt the loading of the program to have it tell you how far along it is.
Usually a loading screen accompanies processes of several parts. For example, if you are loading several image files into textures, you could calculate the total number of images you have to load, then load them one at a time, updating the progress bar between each one to keep the user up-to-date on how many have been loaded.