I had to indent your code for you to understand what you were doing.
#include <stdio.h>
int bar();
main()
{
printf("PING");
printf("%d", bar());
printf("NETSTAT");
printf("%d", bar());
}
bar()
{
int i,j,k,z;
printf("\n");
for(i=0;i<=10;i++)
{
printf("[");
for (j=0;j<i;j++)
printf("=");
for (k=j;k<10;k++)
printf("");
printf("]");
z = (i * 10);
printf("%3d%%", z);
if(z == 100)
{
printf(" [COMPLETED]");
}
printf("\r");
fflush(stdout);
usleep(59000);
}
printf("\n");
}
See the lines in red. That's where the extra numbers are coming from -- the extra print statement to print the extra numbers. Changing it from %d to % stops it happening because you're feeding printf a weird enough command string to make it not "work". It'd be better to just not use printf at all, since you don't want it to print a number there. I'm guessing from how you used it that you're confused as to when printf prints where. The answer is, printf always prints to the same place no matter where you call it, so no extra printf in main is needed there.
Since bar is not returning a value, I've made it void. I've also added a return value and return statement for main, since you really do need one -- without it it returns an unpredictable value. I've had that come back to bite me when scripts using my programs saw the nonzero return, assumed that meant error, and died...
Your k variable is also redundant. You can just reuse it in the second loop instead of adding a brand new var. And your z variable doesn't have much point. Best to minimize the number of variables so you can tell what's going on...
#include <stdio.h>
void bar();
int main()
{
printf("PING");
bar();
printf("NETSTAT");
bar();
return(0);
}
void bar()
{
int i,j;
printf("\n");
for(i=0;i<=10;i++)
{
printf("[");
for (j=0;j<i;j++)
printf("=");
for (; j<10;j++)
printf(" ");
printf("]");
printf("%3d%%", i*10);
if(i == 10)
{
printf(" [COMPLETED]");
}
printf("\r");
fflush(stdout);
usleep(59000);
}
printf("\n");
}
As for opening an HTML file, that's not really HTML specific. The answer is, you run the program that handles the file. Or, for complicated enough GUI systems, you can run a command that decides what program to use and open it for you. OSX has this as the open command:
$ man open
OPEN(1) BSD General Commands Manual OPEN(1)
NAME
open -- open files and directories
SYNOPSIS
open [-a application] file ...
open [-b bundle_identifier] file ...
open [-e] file ...
open [-t] file ...
open [-f]
DESCRIPTION
The open command opens a file (or a directory or URL), just as if you had
double-clicked the file's icon. If no application name is specified, the
default application as determined via LaunchServices is used to open the
specified files.
You should be able to use it like
system("open /path/to/file.html");
[edit] I think I misunderstood you, and you want to interface your program with web pages and not just send your client to them. There's no simple way to do it, as it's not a particularly simple process; you should use a library like libcurl or an external program like wget. I think OSX comes with -lcurl, but doesn't come with wget.