Ah guys, so much replies, and so much no content for some.
Surely a console based cp way, since cp is nothing else than cp:
whereis cp
A simple possible starting point is here. So there are many ways to make cool cp looking with a great progress bar.
Simply that's probably not the right place, forum, public,... about C coding maybe...
I wanted to exchange about some possible codes. well
Code:
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#define MAXLINE 10 // in the book this is 1000
void copy(char to[], char from[])
{
int i;
i = 0;
while((to[i] = from[i]) != '\0')
++i;
}
int main(int argc, char *argv[])
{
int i;
// use heap memory as many modern systems do
char *line = malloc(MAXLINE);
char *longest = malloc(MAXLINE);
assert(line != NULL && longest != NULL && "memory error");
// initialize it but make a classic "off by one" error
for(i = 0; i < MAXLINE; i++) {
line[i] = 'a';
}
// cause the defect
copy(longest, line);
free(line);
free(longest);
return 0;
}
with another layer with sthg similar to such as this:
Code:
#include <stdio.h>
int main(void)
{
char *tu="*";
int i;
for(i=0;i<=100;i++) {
printf("[%s %d", tu,i); printf("\r");
fflush(stdout);
usleep(1000);
}
}
Bookmarks