Originally posted by mart_man00
i forgot to mention that function process calls error() if the file isnt found/readable. but still why is error being called?
Um, because you keep calling it? You really should try using code tags:
[code]
...your code here...
[/code]
Like so:
Code:
int main(int argc, char *argv[]) {
char file[255];
char file2[255];
/**
*** Replace this:
if(argv[1] != (NULL)) {
***With this:
**/
if( argc > 1 ) {
int x = 1;
/**
*** And this:
while(argv[x] != NULL) {
*** With this:
**/
for( x = 0; x < argc; x++ ) {
strcpy(file, argv[x]);
strcpy(file2, argv[x]);
printf("Converting %s ", argv[x]);
if( (process(argv[x], convertfileext(file, ".html"), createtitle(file2))) == 0)
printf("...Done.\n");
}
} else {
char input[255];
char exitnow[5] = "exit";
/**
*** And here is your error() call.
**/
error();
while((strcmp(input, exitnow)) != 0) {
/**
*** Personally, I'd drop scanf()
*** and use fgets(), but that's
*** just me.
**/
scanf("%s", input);
strcpy(file, input);
strcpy(file2, input);
printf("Converting %s ", input);
if( (process(input, convertfileext(file, ".html"), createtitle(file2))) == 0)
printf("...Done.\n");
}
}
/**
*** Since this is main(), which is
*** always a non void function,
*** the only polite thing to do is
*** to return something.
**/
return 0;
}
So much cleaner now...
Quzah.