hey, i did some searches at the forum, but was not quite satisfied with the solution it came up with
any help is appreciatedCode:#include <stdlib.h> #include <stdio.h> #include <string.h> #define TO_REMOVE . #define TO_REPLACE _ // voorzichtig, een lege character.. int main(int argc, char *argv[]) { // variabelen FILE *fFile1; FILE *fFile2; FILE *tmpFile; char filenaam[150]; char toremove; int i; //---------------- if (argc < 2) { fprintf(stdout, "\nERROR: geen bestand opgegeven\n"); fprintf(stdout, "\n\nGebruik als volgt: rename <filenaam>\nBijvoorbeeld: rename 101.60.12.dwg"); exit(EXIT_FAILURE); } // open het bestand (argv[1]) if (strlen(argv[1]) > 150) { fprintf(stdout, "\nERROR: filenaam te lang\n"); exit(EXIT_FAILURE); } // kopieer argument 1 naar de filenaam var, strcpy(filenaam, argv[1]); // open het bestand fFile1 = fopen(filenaam, "r"); //bestaat het bestand niet? if (fFile1 == NULL) { fprintf(stdout, "\nERROR: file bestaat niet of kan niet geopend worden"); exit(EXIT_FAILURE); } //open de tmpfile tmpFile = fopen("tmp", "w"); //bestaat ie niet? if (tmpFile == NULL) { fprintf(stdout, "\nERROR: tmp bestaat niet of kan niet geopend worden"); } //schrijf de file-naam naar het bestand for (i = 0; i < strlen(filenaam); i++) { if (filenaam[i] == '.') { /*HERE IS MY BOTTLENECK, HOW DO I REMOVE THE .? */ strcpy(toremove, filenaam[i]); remove(toremove); } } //sluit alle2 de bestanden voor de zekerheid //fclose(tmpFile); //fclose(fFile1); // geef een goedmelding fprintf(stdout, "Klaar, bestand met succes gewijzigd"); return 0; }
(i know the coding could be done alot more beautiful but first i need to get this straight :>



LinkBack URL
About LinkBacks



)