backup.c

Discussion in 'Software' started by JJJIrish05, Mar 4, 2008.

  1. JJJIrish05

    JJJIrish05 Sergeant

    Ok I'm writing a backup program in C for school. We have to write it in two versions (or just use two different functions with one main and let them choose which to use). One has to use systems calls such as open, read, write, close... and the other has to use ANSI C I/O calls such as fopen, fread, fwrite, and fclose.

    I've been able to find info on how to use fopen and stuff but I can't find a good source for how to use open etc... Can anyone give me a good example that shows me how they are used or link me or explain how they are used?
     
  2. JJJIrish05

    JJJIrish05 Sergeant

    another question.... whats wrong with this?

    backup.c:54: error: 'stdbackup' was not declared in this scope

    stdbackup(dir_to_copy, strcat(dir_to_copy, "BackStd"));

    void stdbackup(char* origPath, char* backupPath)

    char dir_to_copy[MAX_DIR_PATH + 1];



    and if anyone knows getting an error with mkdir:

    /usr/include/sys/stat.h:317: error: too few arguments to function 'int mkdir(const char*
    , __mode_t)'
    backup.c:57: error: at this point in file

    mkdir(strcat(dir_to_copy, "BackSys"));

    what is __mode_t?
     
  3. JJJIrish05

    JJJIrish05 Sergeant

    Ok... figured out mkdir but got a couple others. First let me reword the first error:

    error: backup.c:54: error: 'stdbackup' was not declared in this scope
    stdbackup declaration: void stdbackup(char* origPath, char* backupPath)
    call to stdbackup: stdbackup(dir_to_copy, strcat(dir_to_copy, "BackStd"));
    dir_to_copy declatartion: char dir_to_copy[MAX_DIR_PATH + 1];
    dir_to_copy assignment: getcwd (dir_to_copy, MAX_DIR_PATH + 1);

    1. Is dir_to_copy supposed to be a char*? Because I tried that and then I just got a bunch of errors saying cannot convert 'char**' to 'char*'.
    2. In the call to stdbackup will having the strcat in there allow me to send the two slightly different paths or will I have to put the new path in a new variable? char or char*?
    3. What do I do to fix that error?




    Error 2: backup.c:151: error: invalid conversion from 'int' to 'FILE*'
    error line: f_from=open(strcat(backupPath, entry->d_name), 777);
    f_from declaration: FILE *f_from;
    backupPath declaration: void sysbackup(char* origPath, char* backupPath) //backupPath is an argument taken in from the function call
    entry declaration: struct dirent *entry;
    entry assignment: entry = readdir (dir)
    dir declaration: DIR *dir;
    dir assignemtn: dir = opendir (".");

    1. Totally confused at what's going on. How do I fix it?
    2. Please don't tell me to change open to fopen, can't, it's homework and we can't use fopen.... have to use the system call :(




    Please make any suggestions or link to me to anywhere that might help. Even if you haven't used C but you have used C++ you can probably still help since they are very similar, so any thoughts or ideas would be freaking awesome!!!!
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds