1 #include <stdio.h> 2 #include <stdlib.h> 3 4 #define MAX_LEN 100 5 6 int main ( void ) { 7 8 char buffer[MAX_LEN]; 9 int num; 10 char num2[MAX_LEN]; 11 12 if(fgets(buffer, MAX_LEN, stdin) == NULL) 13 return 1; 14 15 num = atoi(buffer); 16 17 /* Converts num to octal and stores it on num2 str; */ 18 sprintf(num2, "%o\n", num); 19 20 /* prints the string with the octal number; */ 21 printf("%s", num2); 22 return 0; 23 }