Thread: Program I/0 help

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    9

    Program I/0 help

    Can anyone tell me how to delete a file in the same folder as the .exe file?
    Thanks for your help!
    -KaibaFan321

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Tutorial on File I/O
    [edit] It's Under Useful Functions [/edit]
    Last edited by prog-bman; 07-09-2004 at 07:57 PM.
    Woop?

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by KaibaFan321
    Can anyone tell me how to delete a file in the same folder as the .exe file?
    Thanks for your help!
    -KaibaFan321
    Code:
    int main(int argc, char ** argv) {
     int error, status = 0;
     const char * errname = 0;
     while(*(++argv)) {
      printf("Deleting '%s'...", *argv); 
      error = remove(*argv);
      if(error) {
       status = error;
       errname = "Failed";
       } else {
       errname = "Success";
       }
      printf("%s (%d).\n", errname, error);
      }
     return status;
    }
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>error = remove(*argv);
    >>status = error;
    >>return status;
    A minor point, but be warned that you could be returning undefined values, as remove() will return non-zero on error.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  2. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM