#include int main() { unsigned char a = 5, b = 9; // a = 5(00000101), b = 9(00001001) printf("a = %d, b = %d\n", a, b); printf("a&b = %d\n", a&b); // The result is 00000001 printf("a|b = %d\n", a|b); // The result is 00001101 printf("a^b = %d\n", a^b); // The result is 00001100 printf("~a = %d\n", a = ~a); // The result is 11111010 printf("b<<1 = %d\n", b<<1); // The result is 00010010 printf("b>>1 = %d\n", b>>1); // The result is 00000100 return 0; } //%args:"Chi Troppo Vuole" #include #include #include char *xor(char *string, const char *key) { char *s = string; size_t length = strlen(key), i = 0; while (*s) { *s++ ^= key[i++ % length]; } return string; } void hexPrint(char *s) { for (int i=0; i #include int main(void) { struct dirent *de; // Pointer for directory entry // opendir() returns a pointer of DIR type. DIR *dr = opendir("."); if (!dr){ perror("Opendir ."); return -1; } while ((de = readdir(dr)) != NULL) { printf("%30s %ld\n", de->d_name,de->d_ino); } closedir(dr); return 0; } //%args:work #include #include #include #include #include void printFileProperties(struct stat stats); int main(int argc, char *argv[]) { char path[100]; struct stat stats; if (argc!=2) { exit(-1); } // stat() returns 0 on successful operation, // otherwise returns -1 if unable to get file properties. if (stat(argv[1], &stats)) { perror("stat"); } printFileProperties(stats); return 0; } /** * Function to print file properties. */ void printFileProperties(struct stat stats) { struct tm dt; // File permissions printf("\nFile access: "); if (stats.st_mode & R_OK) printf("read "); if (stats.st_mode & W_OK) printf("write "); if (stats.st_mode & X_OK) printf("execute"); // File size printf("\nFile size: %ld", stats.st_size); // Get file creation time in seconds and // convert seconds to date and time format dt = *(gmtime(&stats.st_ctime)); printf("\nCreated on: %d-%d-%d %d:%d:%d", dt.tm_mday, dt.tm_mon, dt.tm_year + 1900, dt.tm_hour, dt.tm_min, dt.tm_sec); // File modification time dt = *(gmtime(&stats.st_mtime)); printf("\nModified on: %d-%d-%d %d:%d:%d", dt.tm_mday, dt.tm_mon, dt.tm_year + 1900, dt.tm_hour, dt.tm_min, dt.tm_sec); }