It's UWAweek 48

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

Displaying the 4 articles in this topic
Showing 4 of 919 articles.
Currently 15 other people reading this forum.


 UWA week 33 (2nd semester, week 4) ↓
SVG not supported

Login to reply

👍?
helpful
12:03pm Mon 15th Aug, Haoxuan L.

In the workshop there says printf("haversine distance =%.1fm\n", haversince function(....); I understand the \n and %i etc, but can you go through the %.1fm a bit more? Tried googling it but it seems like I dont know how to ask a good questions and find answers with the symbols.


SVG not supported

Login to reply

👍?
helpful
12:09pm Mon 15th Aug, Haoxuan L.

Also another question, I can't use exit(0) and exit (1) as when I compile "haversine.c:27:5: error: incompatible implicit declaration of built-in function ‘exit’ [-Werror] 27 | exit(0);" But I can compile with exit(EXIT_FAILURE); Just wondering why this happens


SVG not supported

Login to reply

👍x1
helpful
12:10pm Mon 15th Aug, Christopher M.

Certainly. reading from left-to-right the '%' character starting for format specifier, the '.' begins a request for a number of decimal-points, the '1' says one digit to the right of the decimal-point, the 'f' says we're formatting a floating-point value, and the 'm' is not really part of it - it's just the 'm' for metres. https://www.tutorialspoint.com/format-specifiers-in-c https://www.cprogramming.com/tutorial/printf-format-strings.html


SVG not supported

Login to reply

👍?
helpful
12:12pm Mon 15th Aug, Christopher M.

"Haoxuan Long" <23*4*1*[email protected]*u*e*t*u*a*e*u*a*> wrote:
> Also another question, I can't use exit(0) and exit (1) > as when I compile > "haversine.c:27:5: error: incompatible implicit declaration of built-in function ‘exit’ [-Werror] > 27 | exit(0);" > > But I can compile with exit(EXIT_FAILURE); > Just wondering why this happens
Are you #include-ing <stdlib.h> in all cases? It provides both the declaration for the exit() function, and the constants EXIT_SUCCESS and EXIT_FAILURE.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  1:17AM Sep 14 2022
Privacy policy