fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. double C_to_F(double tempr);
  5. double F_to_C(double tempr);
  6.  
  7. int main(int argc, char *argv[]) {
  8. // your code goes here
  9. if (argc != 3) {
  10. printf("Usage: ./name number system[C for Celsius, F for Farenheit]");
  11. return 1;
  12. }
  13. double tempr = atoi(argv[1]);
  14. if (argv[1] == "C") {
  15. //todo
  16. printf("%lf F\n", C_to_F(tempr));
  17. } else if (argv[2] == "F") {
  18. //todo
  19. printf("%lf C\n", F_to_C(tempr));
  20. }
  21. else
  22. printf("Wrong system\n");
  23. return 0;
  24. }
  25. double C_to_F(double tempr)
  26. {
  27. return tempr * (5/9) + 32;
  28. }
  29. double F_to_C(double tempr)
  30. {
  31. return (tempr - 32) * (5 /9);
  32. }
  33.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:14:14: error: comparison with string literal results in unspecified behavior [-Werror=address]
  if (argv[1] == "C") {
              ^
prog.c:17:21: error: comparison with string literal results in unspecified behavior [-Werror=address]
  } else if (argv[2] == "F") {
                     ^
cc1: all warnings being treated as errors
stdout
Standard output is empty