Thread: remove() and rename()

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    26

    remove() and rename()

    Well, first of all I tried using these in my function and it doesn't seem to do anything. That, I'm sure, can be worked out. However, if I'm not mistaken these are C functions. I've searched and haven't been able to find any standard C++ specific functions to do the same tasks. Suggestions?
    --LiKWiD
    Becoming un-noobified one day at a time.

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    However, if I'm not mistaken these are C functions.
    I believe they are c++ functions.
    for a reference
    http://msdn.microsoft.com/library/de..._._wrename.asp
    Well, first of all I tried using these in my function and it doesn't seem to do anything.
    We could probably help with that, post some code please.

  3. #3

  4. #4
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    The links you gave point to MFC references, I don't think that's what LiKWiD intends...

  5. #5
    Registered User
    Join Date
    Mar 2005
    Posts
    7
    Good point. I didn't read fully I guess.. </LIFE>

    To correct myself, just use:
    Code:
    rename(old filename, new filename);
    remove(filename);
    the filenames are char's.
    Last edited by anthrax759; 03-21-2005 at 06:22 PM.

  6. #6
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Quote Originally Posted by anthrax759
    Good point. I didn't read fully I guess.. </LIFE>

    To correct myself, just use:
    Code:
    rename(old filename, new filename);
    remove(filename);
    the filenames are char's.

    i though the directory went in the (" ") ? maybe i am wrong?

    Code:
    remove("C:\\");
    rename("C:\\rename\\rename.txt", "C:\\rename\\rename2.txt");
    am i wrong?

  7. #7
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    No, but I don't see how that relates to the quote you gave.

  8. #8
    Registered User
    Join Date
    Jul 2003
    Posts
    26
    Code:
    remove(filename.c_str());
    rename("temp.ini", filename.c_str());
    It wasn't working in my proggie at first because I hadn't closed the files before trying to rename/remove them. Everything works fine now. I was just curious if there was something specific to C++ that I could use instead of that, but I guess that is it. Thanks.
    --LiKWiD
    Becoming un-noobified one day at a time.

  9. #9
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    C++ doesn't have any functions that delete or rename files.
    Woop?

  10. #10
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    The C++ standard disagrees.
    The C + + Standard library provides 209 standard functions from the C library, as shown in Table 99:
    Table 99—Standard Functions
    _ __________________________________________________ ________________________
    abort fmod isupper mktime strftime wcrtomb
    abs fopen iswalnum modf strlen wcscat
    acos fprintf iswalpha perror strncat wcschr
    asctime fputc iswcntrl pow strncmp wcscmp
    asin fputs iswctype printf strncpy wcscoll
    atan fputwc iswdigit putc strpbrk wcscpy
    atan2 fputws iswgraph putchar strrchr wcscspn
    atexit fread iswlower puts strspn wcsftime
    atof free iswprint putwc strstr wcslen
    atoi freopen iswpunct putwchar strtod wcsncat
    atol frexp iswspace qsort strtok wcsncmp
    bsearch fscanf iswupper raise strtol wcsncpy
    btowc fseek iswxdigit rand strtoul wcspbrk
    calloc fsetpos isxdigit realloc strxfrm wcsrchr
    ceil ftell labs remove swprintf wcsrtombs
    clearerr fwide ldexp rename swscanf wcsspn
    clock fwprintf ldiv rewind system wcsstr
    cos fwrite localeconv scanf tan wcstod
    cosh fwscanf localtime setbuf tanh wcstok
    ctime getc log setlocale time wcstol
    difftime getchar log10 setvbuf tmpfile wcstombs
    div getenv longjmp signal tmpnam wcstoul
    exit gets malloc sin tolower wcsxfrm
    exp getwc mblen sinh toupper wctob
    fabs getwchar mbrlen sprintf towctrans wctomb
    fclose gmtime mbrtowc sqrt towlower wctrans
    feof isalnum mbsinit srand towupper wctype
    ferror isalpha mbsrtowcs sscanf ungetc wmemchr
    fflush iscntrl mbstowcs strcat ungetwc wmemcmp
    fgetc isdigit mbtowc strchr vfprintf wmemcpy
    fgetpos isgraph memchr strcmp vfwprintf wmemmove
    fgets islower memcmp strcoll vprintf wmemset
    fgetwc isprint memcpy strcpy vsprintf wprintf
    fgetws ispunct memmove strcspn vswprintf wscanf
    floor isspace memset strerror vwprintf
    **EDIT**
    Quoted from Thantos, in this thread.
    Last edited by Hunter2; 03-21-2005 at 08:23 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  11. #11
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Intresting thanks hunter
    Woop?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deleting multiple files using C
    By dj.turkmaster in forum C Programming
    Replies: 8
    Last Post: 01-26-2009, 12:31 PM
  2. Running remove() gets permission denied error...
    By edomingox in forum C Programming
    Replies: 4
    Last Post: 01-11-2009, 12:55 PM
  3. c++ equivalent of remove and rename
    By vaibhav in forum C++ Programming
    Replies: 3
    Last Post: 01-01-2006, 10:35 AM
  4. Hex Editing - Remove first 15 bytes
    By xTrinity in forum C++ Programming
    Replies: 13
    Last Post: 08-13-2003, 09:01 PM